[Insight-users] LabelShapeOpeningImageFilter Attribute input =?
Ella Maria Kadas
ella_kadas at yahoo.com
Wed Mar 30 06:09:12 EDT 2011
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 Lehmannimplemented 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110330/d7410055/attachment.htm>
More information about the Insight-users
mailing list