<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi all,<div><br></div><div> I am trying to remove some objects from a 3D image that have a volume lower then a specific value.</div><div> I tried to use the <span class="Apple-style-span" style="color: rgb(26, 26, 24); "><font class="Apple-style-span" face="'times new roman', 'new york', times, serif"><span class="Apple-style-span" style="font-size: small;">Label object representation and manipulation with ITK that </span></font></span><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); ">Gae ̈tan Lehmann</span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); ">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 </span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "></span><span class="Apple-style-span" style="font-family: Courier; color: rgb(26, 26, 24); "><span class="Apple-style-span" style="font-size: small;">size = itk.ShapeOpeningLabelMapFilter[LabelMapType].New(stats,Attribute=’Size’, Lambda=100</span></span><span class="Apple-style-span" style="font-family: Courier; font-size: 9px; color: rgb(26, 26, 24); ">) </span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "> I want to use the ShapeLabelObject, and it's attributes to do a LabelShapeOpeningFilter.</span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "> As i was getting no result i tried to do it in 2D first.</span></div><div><span class="Apple-style-span"
style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "> This is my code:</span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); ">First i use the ConnectedComponentImageFilter, then RelabelComponentImageFilter and create a ShapeLabelMap from the relabel's output.</span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "><br></span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000">typedef unsigned long LabelType;</font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000"> typedef itk::ShapeLabelObject< LabelType, dim > LabelObjectType;</font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000"> typedef itk::LabelMap< LabelObjectType > LabelMapType;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><font class="Apple-style-span" color="#000000"><br></font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000"><br></font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000"> typedef itk::LabelImageToShapeLabelMapFilter< LabelImageType, LabelMapType > ConverterType;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> ConverterType::Pointer converter = ConverterType::New();</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> converter->SetInput( relabel->GetOutput() );</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> converter->Update();</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; ">!!!! Why does it not work if i use this part of code from the journal<span class="Apple-tab-span" style="white-space: pre; ">        </span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>/*</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><p
style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times; color: #1a1a18">a<span class="Apple-style-span" style="font-size: small;">nd valuate the attributes with the dedicated filter: ShapeLabelMapFilter</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.2px Courier; color: #1a1a18"><span class="Apple-style-span" style="font-size: small;">typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType; ShapeFilterType::Pointer shape = ShapeFilterType::New(); shape->SetInput( converter->GetOutput() );</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Times; color: #1a1a18"><span class="Apple-style-span" style="font-size: small;">update the shape filter, so its output will be up to date</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.2px Courier; color: #1a1a18"><span class="Apple-style-span" style="font-size: small;">shape->Update();</span></p></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; min-height: 13px; ">*/</p></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><br></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"> <font class="Apple-style-span" color="#000000">LabelMapType::Pointer labelMap = converter->GetOutput();</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000">std::cout<<"nr of label objects"<<labelMap->GetNumberOfLabelObjects()<<std::endl;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><font class="Apple-style-span" color="#000000"><br></font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> for( unsigned int label=1; label<=labelMap->GetNumberOfLabelObjects(); label++ )</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> {</font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000"> </font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> const LabelObjectType * labelObject = labelMap->GetLabelObject( label );</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> std::cout << label << "\t" << labelObject->GetPhysicalSize() << "\t" << labelObject->GetCentroid() << std::endl;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000"> }</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><font class="Apple-style-span" color="#000000"><br></font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">typedef itk::LabelShapeOpeningImageFilter< LabelImageType > LabelOpeningType;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">LabelOpeningType::Pointer opening = LabelOpeningType::New();</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">opening->SetInput( relabel->GetOutput());</font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">opening->SetBackgroundValue(0);</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">opening->SetLambda( 100 );</font></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">opening->SetReverseOrdering( false );</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000">//NO IDEA About the Attribute</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><font class="Apple-style-span" color="#000000">//I thought it should be the labelMap->Size()) should be as attribute</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">opening->SetAttribute("PERIMETER");</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span><font class="Apple-style-span" color="#000000">itk::SimpleFilterWatcher watcher(opening, "filter");</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#000000">        </font></span></p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre">T</span>hen 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</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>/*typedef itk::LabelMapToLabelImageFilter< LabelImageType, LabelImageType > L2IType; </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>L2IType::Pointer l2i = L2IType::New(); </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>l2i->SetInput( opening->GetOutput() );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e; min-height: 13.0px"><span class="Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>typedef itk::ImageFileWriter< LabelImageType > WriterType;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>WriterType::Pointer writer = WriterType::New();</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>writer->SetInput( l2i->GetOutput() );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>writer->SetFileName( "/Users/ellaK/Documents/Morphology/Opening.gipl");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #06830e"><span class="Apple-tab-span" style="white-space:pre">        </span>writer->Update();*/</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d2380"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="color: #6f41a8">s</span><font class="Apple-style-span" color="#000000">td::getchar();</font></p><div><span style="color: #000000"><br></span></div><div><span style="color: #000000"><br></span></div><div><span style="color: #000000"><br></span></div><div><span style="color: #000000">Maybe i am doing this the wrong way, and i can't use it for 3D images.</span></div><div><span style="color: #000000">If anybody already already worked with this filters please give me a hint to what i am doing wrong.</span></div><div><span style="color: #000000">Thanks,</span></div><div><span style="color: #000000"> Ella</span></div></span></div></td></tr></table>