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.<span class="Apple-style-span" style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; "><h3 style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 14px; ">

<a href="http://www.itk.org/Doxygen318/html/classitk_1_1BinaryShapeKeepNObjectsImageFilter.html#_details">http://www.itk.org/Doxygen318/html/classitk_1_1BinaryShapeKeepNObjectsImageFilter.html#_details</a></h3><div><span class="Apple-style-span" style="font-family: arial; font-size: small; ">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.</span></div>

</span><br><div class="gmail_quote">2011/5/16 LaMoOsH .. <span dir="ltr">&lt;<a href="mailto:xlolla28x@hotmail.com">xlolla28x@hotmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div>
Hi everyone, i have two regions in my image .. <br>
it is a binary image .. <br>
i used label map to label these object .. <br>
how can i say that i want to pick the largest region among these two regions ?<br>
i want to pic the largest to apply a some filters on it .. <br>
 <br>
 <br>
This is my code and dont know how to finish it  <br>
 <br><font color="#0000ff" size="2"><font color="#0000ff" size="2">
typedef</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">long</font></font><font size="2"> LabelType; <br>


</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::ShapeLabelObject&lt; LabelType, 2 &gt; LabelObjectType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::LabelMap&lt; LabelObjectType &gt; LabelMapType;<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">typedef</font></font><font size="2"> itk::BinaryImageToShapeLabelMapFilter&lt; OutputImageType, LabelMapType &gt; ConverterType;<br>
ConverterType::Pointer converter = ConverterType::New(); <br>
converter-&gt;SetInputForegroundValue( 255 );<br>
LabelMapType::Pointer labelMap = converter-&gt;GetOutput();<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">for</font></font><font size="2">( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> label=1; label&lt;=labelMap-&gt;GetNumberOfLabelObjects(); label++ ) <br>


{<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">const</font></font><font size="2"> LabelObjectType * labelObject = labelMap-&gt;GetLabelObject( label ); </font><br>
<font size="2"></font> <br>
<font size="2"></font> <br>
<font size="2">Thanks <br></font>                                               </div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>