[Insight-users] get largest labeled region

Neil Panjwani paniwani at gmail.com
Mon May 16 17:04:31 EDT 2011


If you have a binary image with several objects and you want to selectively
apply some filters to only the largest object, use the
BinaryShapeKeepNObjectsImageFilter.
http://www.itk.org/Doxygen318/html/classitk_1_1BinaryShapeKeepNObjectsImageFilter.html#_details
After inputing a binary image, set the number of objects to keep (in this
case 1), foreground and background value, attribute used for sorting (size),
and optionally reverse ordering (largest or smallest). The filter will
return a binary image with only the selected objects which you can then
apply your filters to.

2011/5/16 LaMoOsH .. <xlolla28x at hotmail.com>

>  Hi everyone, i have two regions in my image ..
> it is a binary image ..
> i used label map to label these object ..
> how can i say that i want to pick the largest region among these two
> regions ?
> i want to pic the largest to apply a some filters on it ..
>
>
> This is my code and dont know how to finish it
>
> typedef unsigned long LabelType;
> typedef itk::ShapeLabelObject< LabelType, 2 > LabelObjectType;
> typedef itk::LabelMap< LabelObjectType > LabelMapType;
> typedef itk::BinaryImageToShapeLabelMapFilter< OutputImageType,
> LabelMapType > ConverterType;
> ConverterType::Pointer converter = ConverterType::New();
> converter->SetInputForegroundValue( 255 );
> LabelMapType::Pointer labelMap = converter->GetOutput();
> for( unsigned int label=1; label<=labelMap->GetNumberOfLabelObjects();
> label++ )
> {
> const LabelObjectType * labelObject = labelMap->GetLabelObject( label );
>
>
> Thanks
>
> _____________________________________
> 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/20110516/5cf298e9/attachment.htm>


More information about the Insight-users mailing list