Hello, <br><br>It concerned to itk::LabelMap, itk::ShapeLabelObject, itk::LabelMapToLabelImageFilter<br><br>I have a question about how to change the label value of label object in a label map and convert into an new label image.<br>
<br>I try to assign each label object in a label map with a new label value by using &quot;labelObj-&gt;SetLabel(new_value)&quot;. However, after I converted the label Map into an label image using &quot;itk::LabelMapToLabelImageFilter&quot; , the label value of the coverted image doesn&#39;t change to new_value.<br>
<br>The code looks like below:<br>// read and convert image into a labelmap<br>...<br>LabelMapType::Pointer labelMap = converter-&gt;GetOutput();<br>LabelMapType::LabelObjectContainerType::iterator it;<br>LabelMapType::LabelObjectContainerType &amp; labelObjectContainer = labelMap-&gt;GetLabelObjectContainer();<br>
for( it = labelObjectContainer.begin(),it != labelObjectContainer.end(); it++)<br>{<br>   ...<br>   new_value = image2-&gt;GetPixel(index);<br>//!!!try to change the label here!!!<br>   it-&gt;second-&gt;SetLabel(new_value);<br>
}<br><br>typedef itk::LabelMapToLabelImageFilter&lt; LabelMapType, LacunaDistanceImageType &gt; M2IFilterType;<br><br>  M2IFilterType::Pointer m2i = M2IFilterType::New();<br>     m2i-&gt;SetInput(labelMap);//The labels remain the same?!<br>
     m2i-&gt;Update();<br>//save image...<br>     ...<br>     writer-&gt;GetInput(m2i-&gt;GetOutput());<br><br>Thanks in advance!<br><br>Sincerely,<br>Pei DONG<br><br>