<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi all,<div><br></div><div>&nbsp;&nbsp; &nbsp;I am trying to remove some objects from a 3D image that have a volume lower then a specific value.</div><div>&nbsp;&nbsp; I tried to use the&nbsp;<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&nbsp;</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&nbsp;</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); ">)&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: small; color: rgb(26, 26, 24); ">&nbsp;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); ">&nbsp;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); ">&nbsp;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">&nbsp; typedef itk::ShapeLabelObject&lt; LabelType, dim &gt; 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">&nbsp; typedef itk::LabelMap&lt; LabelObjectType &gt; 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">&nbsp; typedef itk::LabelImageToShapeLabelMapFilter&lt; LabelImageType, LabelMapType &gt; 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">&nbsp; 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">&nbsp; converter-&gt;SetInput( relabel-&gt;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">&nbsp; converter-&gt;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&lt; LabelMapType &gt; ShapeFilterType; ShapeFilterType::Pointer shape = ShapeFilterType::New(); shape-&gt;SetInput( converter-&gt;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-&gt;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">&nbsp;&nbsp;<font class="Apple-style-span" color="#000000">LabelMapType::Pointer labelMap = converter-&gt;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&lt;&lt;"nr of label objects"&lt;&lt;labelMap-&gt;GetNumberOfLabelObjects()&lt;&lt;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">&nbsp; for( unsigned int label=1; label&lt;=labelMap-&gt;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">&nbsp; &nbsp; {</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">&nbsp; &nbsp;&nbsp;</font></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo"><font class="Apple-style-span" color="#000000">&nbsp; &nbsp; const LabelObjectType * labelObject = labelMap-&gt;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">&nbsp; &nbsp; std::cout &lt;&lt; label &lt;&lt; "\t" &lt;&lt; labelObject-&gt;GetPhysicalSize() &lt;&lt; "\t" &lt;&lt; labelObject-&gt;GetCentroid() &lt;&lt; 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">&nbsp; &nbsp; }</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&lt; LabelImageType &gt; 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-&gt;SetInput( relabel-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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-&gt;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&lt; LabelImageType, LabelImageType &gt; L2IType;&nbsp;</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();&nbsp;</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-&gt;SetInput( opening-&gt;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&lt; LabelImageType &gt; 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-&gt;SetInput( l2i-&gt;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-&gt;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-&gt;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">&nbsp;&nbsp; Ella</span></div></span></div></td></tr></table>