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 "labelObj->SetLabel(new_value)". However, after I converted the label Map into an label image using "itk::LabelMapToLabelImageFilter" , the label value of the coverted image doesn'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->GetOutput();<br>LabelMapType::LabelObjectContainerType::iterator it;<br>LabelMapType::LabelObjectContainerType & labelObjectContainer = labelMap->GetLabelObjectContainer();<br>
for( it = labelObjectContainer.begin(),it != labelObjectContainer.end(); it++)<br>{<br> ...<br> new_value = image2->GetPixel(index);<br>//!!!try to change the label here!!!<br> it->second->SetLabel(new_value);<br>
}<br><br>typedef itk::LabelMapToLabelImageFilter< LabelMapType, LacunaDistanceImageType > M2IFilterType;<br><br> M2IFilterType::Pointer m2i = M2IFilterType::New();<br> m2i->SetInput(labelMap);//The labels remain the same?!<br>
m2i->Update();<br>//save image...<br> ...<br> writer->GetInput(m2i->GetOutput());<br><br>Thanks in advance!<br><br>Sincerely,<br>Pei DONG<br><br>