[Insight-users] Is there any itk::BoundingBox example?
Luis Ibanez
luis.ibanez at kitware.com
Wed Oct 21 13:32:34 EDT 2009
Hi Juliette,
For your convenience,
We just added to ITK an example on how to do this
by using the ImageMaskSpatial object and its method:
GetAxisAlignedBoundingBoxRegion()
This new example is now under the directory:
Insight/Examples/SpatialObjects
The filename is:
BoundingBoxFromImageMaskSpatialObject.cxx
and the essential part of the code is:
typedef itk::ImageMaskSpatialObject<3> ImageMaskSpatialObject;
typedef ImageMaskSpatialObject::ImageType ImageType;
typedef ImageType::RegionType RegionType;
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
reader->Update();
ImageMaskSpatialObject::Pointer maskSO = ImageMaskSpatialObject::New();
maskSO->SetImage ( reader->GetOutput() );
RegionType boundingBoxRegion = maskSO->GetAxisAlignedBoundingBoxRegion();
std::cout << "Bounding Box Region: " << boundingBoxRegion << std::endl;
Here we assume that you are reading a binary image.
Note that the bounding box is actually stored in an
itk::Region<3> class, instead of an itk::BoundingBox
class.
The main difference between these two classes is that the
Region represents pixels (discrete positions on the image
grid), while the itk::BoundingBox represents physical
coordinates in Space.
Another option that you may want to consider is the use
of the LabelMap classes contributed by Gaetan Lehmann.
http://www.insight-journal.org/browse/publication/176
These classes are now in the directory:
Insight/Code/Review
In particular the
itkAutoCropLabelMapFilter.h
will do both:
* Computing the bounding box
* Extracting that region from the image.
These family of classes will also compute features
such as the center of gravity, if you actually need
such values as well.
Regards,
Luis
-------------------------------------------------------------------------------------
On Mon, Oct 19, 2009 at 6:48 AM, Juliette Deniau
<juliette.deniau at yahoo.fr>wrote:
> Hi,
>
> I would like to get the bounding box of a segmented object . 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 itk::
> BoundingBox<http://www.itk.org/Doxygen316/html/classitk_1_1BoundingBox.html>,
> however I don’t know how? Any help is appreciated.
>
> Thanks
>
> Juliette
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091021/d46fdb01/attachment.htm>
More information about the Insight-users
mailing list