<br>Hi Juliette,<br><br><br>For your convenience,<br><br>We just added to ITK an example on how to do this <br>by using the ImageMaskSpatial object and its method:<br><br>          GetAxisAlignedBoundingBoxRegion()<br><br>
<br>This new example  is now under the directory:<br><br>            Insight/Examples/SpatialObjects<br><br>The filename is:<br><br>   BoundingBoxFromImageMaskSpatialObject.cxx<br><br>and the essential part of the code is:<br>
<br><br> typedef itk::ImageMaskSpatialObject&lt;3&gt;      ImageMaskSpatialObject;<br><br>  typedef ImageMaskSpatialObject::ImageType   ImageType;<br>  typedef ImageType::RegionType               RegionType;<br>  typedef itk::ImageFileReader&lt; ImageType &gt;   ReaderType;<br>
<br>  ReaderType::Pointer reader = ReaderType::New();<br><br>  reader-&gt;SetFileName( argv[1] );<br>  reader-&gt;Update();<br><br>  ImageMaskSpatialObject::Pointer maskSO = ImageMaskSpatialObject::New();<br><br>  maskSO-&gt;SetImage ( reader-&gt;GetOutput() );<br>
<br>  RegionType boundingBoxRegion  = maskSO-&gt;GetAxisAlignedBoundingBoxRegion();<br><br>  std::cout &lt;&lt; &quot;Bounding Box Region: &quot; &lt;&lt; boundingBoxRegion &lt;&lt; std::endl;<br><br><br>Here we assume that you are reading a binary image.<br>
<br>Note  that the bounding box is actually stored in an<br>itk::Region&lt;3&gt; class, instead of an itk::BoundingBox<br>class.<br><br>The main difference between these two classes is that the<br>Region represents pixels (discrete positions on the image <br>
grid), while the itk::BoundingBox represents physical <br>coordinates in Space.<br><br><br>Another option that you may want to consider is the use <br>of the LabelMap classes contributed by Gaetan Lehmann.<br><br>  <a href="http://www.insight-journal.org/browse/publication/176">http://www.insight-journal.org/browse/publication/176</a><br>
<br>These classes are now in the directory:<br><br>           Insight/Code/Review<br><br>In particular the <br><br>          itkAutoCropLabelMapFilter.h<br><br>will do both:<br><br>  * Computing the bounding box<br>  * Extracting that region from the image.<br>
<br>These family of classes will also compute features<br>such as the center of gravity, if you actually need<br>such values as well.<br><br><br>  Regards,<br><br><br>        Luis<br><br><br>-------------------------------------------------------------------------------------<br>
<div class="gmail_quote">On Mon, Oct 19, 2009 at 6:48 AM, Juliette Deniau <span dir="ltr">&lt;<a href="mailto:juliette.deniau@yahoo.fr">juliette.deniau@yahoo.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
<p class="MsoNormal" style="margin: 0cm 0cm 10pt;"><font size="3" face="Calibri">Hi,</font>
</p><p class="MsoNormal" style="margin: 0cm 0cm 10pt;"><font size="3"><font face="Calibri">I would like to get the bounding box of a segmented object .<span>  </span><span style="color: black;">Currently I’m doing that by computing the min, max, and the center of gravity of the object . I would like to do it using the already itk class </span>itk::<span style="color: black;"> </span></font></font><a title="Represent and compute information about bounding boxes." href="http://www.itk.org/Doxygen316/html/classitk_1_1BoundingBox.html" target="_blank"><span style="color: windowtext; text-decoration: none;"><font size="3" face="Calibri">BoundingBox</font></span></a><font size="3"><font face="Calibri">, <span> </span>however<span style="color: black;"> I don’t know how? Any help is appreciated. </span></font></font>
</p><p class="MsoNormal" style="margin: 0cm 0cm 10pt;"><span style="color: black;"><font size="3"><font face="Calibri">Thanks</font></font></span>
</p><p class="MsoNormal" style="margin: 0cm 0cm 10pt;"><font size="3" face="Calibri">Juliette</font></p></td></tr></tbody></table><font color="#888888"><br>



      </font><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>
Please keep messages on-topic and check the ITK FAQ at: <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>