If you are trying to relabel your image based on a specific shape attribute, see:<div><br></div><div><a href="http://www.itk.org/Doxygen318/html/classitk_1_1ShapeRelabelImageFilter.html">http://www.itk.org/Doxygen318/html/classitk_1_1ShapeRelabelImageFilter.html</a></div>
<div><br><div class="gmail_quote">On Fri, May 6, 2011 at 5:40 AM, Pei Dong <span dir="ltr"><<a href="mailto:peidong1030@gmail.com">peidong1030@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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><font color="#888888">Pei DONG<br><br>
</font><br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>