[Insight-users] How to assign a new label value to Label objects in a LabelMap
Neil Panjwani
paniwani at gmail.com
Fri May 6 12:51:03 EDT 2011
If you are trying to relabel your image based on a specific shape attribute,
see:
http://www.itk.org/Doxygen318/html/classitk_1_1ShapeRelabelImageFilter.html
On Fri, May 6, 2011 at 5:40 AM, Pei Dong <peidong1030 at gmail.com> wrote:
> Hello,
>
> It concerned to itk::LabelMap, itk::ShapeLabelObject,
> itk::LabelMapToLabelImageFilter
>
> 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.
>
> 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.
>
> The code looks like below:
> // read and convert image into a labelmap
> ...
> LabelMapType::Pointer labelMap = converter->GetOutput();
> LabelMapType::LabelObjectContainerType::iterator it;
> LabelMapType::LabelObjectContainerType & labelObjectContainer =
> labelMap->GetLabelObjectContainer();
> for( it = labelObjectContainer.begin(),it != labelObjectContainer.end();
> it++)
> {
> ...
> new_value = image2->GetPixel(index);
> //!!!try to change the label here!!!
> it->second->SetLabel(new_value);
> }
>
> typedef itk::LabelMapToLabelImageFilter< LabelMapType,
> LacunaDistanceImageType > M2IFilterType;
>
> M2IFilterType::Pointer m2i = M2IFilterType::New();
> m2i->SetInput(labelMap);//The labels remain the same?!
> m2i->Update();
> //save image...
> ...
> writer->GetInput(m2i->GetOutput());
>
> Thanks in advance!
>
> Sincerely,
> Pei DONG
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110506/c6c4aad7/attachment.htm>
More information about the Insight-users
mailing list