[Insight-users] LabelShapeOpeningImageFilter Attribute input =?

Richard Beare richard.beare at gmail.com
Wed Mar 30 08:03:14 EDT 2011


There is a convenience class in the Review directory that is derived from
this contribution called itk::BinaryShapeOpeningImageFilter. This includes
all of the labelling and conversion to and from label maps. You just need to
call the SetAttribute and SetForegroundValue appropriately. It should work
fine for 3D. If you look inside that class you should also find the standard
combination of steps you need to go through to use the LabelMap filters.

On Wed, Mar 30, 2011 at 9:09 PM, Ella Maria Kadas <ella_kadas at yahoo.com>wrote:

> Hi all,
>
>     I am trying to remove some objects from a 3D image that have a volume
> lower then a specific value.
>    I tried to use the Label object representation and manipulation with
> ITK that Gae ̈tan Lehmann
> implemented but i still don't know what that attribute parameter should
> look like. (in the python example it looks a s it would be a char
> size =
> itk.ShapeOpeningLabelMapFilter[LabelMapType].New(stats,Attribute=’Size’,
> Lambda=100)
>  I want to use the ShapeLabelObject, and it's attributes to do a
> LabelShapeOpeningFilter.
>  As i was getting no result i tried to do it in 2D first.
>  This is my code:
> First i use the ConnectedComponentImageFilter, then
> RelabelComponentImageFilter and create a ShapeLabelMap from the relabel's
> output.
>
> typedef unsigned long LabelType;
>
>   typedef itk::ShapeLabelObject< LabelType, dim > LabelObjectType;
>
>   typedef itk::LabelMap< LabelObjectType > LabelMapType;
>
>
>
>   typedef itk::LabelImageToShapeLabelMapFilter< LabelImageType,
> LabelMapType > ConverterType;
>
>   ConverterType::Pointer converter = ConverterType::New();
>
>   converter->SetInput( relabel->GetOutput() );
>
>   converter->Update();
>
> !!!! Why does it not work if i use this part of code from the journal
>
> /*
>
> and valuate the attributes with the dedicated filter: ShapeLabelMapFilter
>
> typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType;
> ShapeFilterType::Pointer shape = ShapeFilterType::New(); shape->SetInput(
> converter->GetOutput() );
>
> update the shape filter, so its output will be up to date
>
> shape->Update();
>
> */
>
>
>   LabelMapType::Pointer labelMap = converter->GetOutput();
>
> std::cout<<"nr of label
> objects"<<labelMap->GetNumberOfLabelObjects()<<std::endl;
>
>
>   for( unsigned int label=1; label<=labelMap->GetNumberOfLabelObjects();
> label++ )
>
>     {
>
>
>
>     const LabelObjectType * labelObject = labelMap->GetLabelObject( label
> );
>
>     std::cout << label << "\t" << labelObject->GetPhysicalSize() << "\t" <<
> labelObject->GetCentroid() << std::endl;
>
>     }
>
>
>  typedef itk::LabelShapeOpeningImageFilter< LabelImageType >
> LabelOpeningType;
>
> LabelOpeningType::Pointer opening = LabelOpeningType::New();
>
> opening->SetInput( relabel->GetOutput());
>
> opening->SetBackgroundValue(0);
>
> opening->SetLambda( 100 );
>
> opening->SetReverseOrdering( false );
>
> //NO IDEA About the Attribute
>
> //I thought it should be the labelMap->Size()) should be as attribute
>
> opening->SetAttribute("PERIMETER");
>
> itk::SimpleFilterWatcher watcher(opening, "filter");
>
> Then i would like to get back the binary image and see it but i can't get
> the proper image types as input to LabelMapToLabelIamgeFilter....So the
> commented part is not working
>
>
>  /*typedef itk::LabelMapToLabelImageFilter< LabelImageType, LabelImageType
> > L2IType;
>
> L2IType::Pointer l2i = L2IType::New();
>
> l2i->SetInput( opening->GetOutput() );
>
>  typedef itk::ImageFileWriter< LabelImageType > WriterType;
>
> WriterType::Pointer writer = WriterType::New();
>
> writer->SetInput( l2i->GetOutput() );
>
> writer->SetFileName( "/Users/ellaK/Documents/Morphology/Opening.gipl");
>
> writer->Update();*/
>
> std::getchar();
>
>
>
> Maybe i am doing this the wrong way, and i can't use it for 3D images.
> If anybody already already worked with this filters please give me a hint
> to what i am doing wrong.
> Thanks,
>    Ella
>
> _____________________________________
> 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/20110330/26682abb/attachment.htm>


More information about the Insight-users mailing list