# Extracting Bounding Box information from an image

**URL:** <https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883>\
**Category:** Uncategorized\
**Created:** [February 19, 2021, 10:16am UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883 "2021-02-19T10:16:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)\
**Post date:** [February 19, 2021, 10:16am UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883/1 "2021-02-19T10:16:43Z")

</div>

HI! Is there a way to load nifty image and extract its bounding box coordinates from it? If I am not mistaken, bounding box within nifty image is called largest possible region in ITK, correct?

I would like to measure hight of the bounding box to try and quantify how much of a specific anatomy is contained within an image.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [February 19, 2021, 2:19pm UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883/2 "2021-02-19T14:19:27Z")

</div>

Largest possible region is measured in index (ijk) coordinates, you probably want physical coordinates. Go through 8 corners of the image, and for each of them call [TransformIndexToPhysicalPoint](https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#ae2e113c2ff7bab1a145c27a30584a2ac). From those 8 points with coordinates in millimeters you can asses “height” of the field of view.

---

<div class="post-metadata">

**Author:** ![Stefan\_Radonjic](https://discourse.itk.org/user_avatar/discourse.itk.org/stefan_radonjic/32/1793_2.png) [@Stefan\_Radonjic](https://discourse.itk.org/u/Stefan_Radonjic)\
**Post date:** [February 19, 2021, 2:28pm UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883/3 "2021-02-19T14:28:19Z")

</div>

So if I understood correctly I would first call **LargestPossibleRegion** to get index coordinates. And then go through 8 corners of the largest possible region and call **TransformIndexToPhysicalPoint**. Correct?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [February 19, 2021, 2:29pm UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883/4 "2021-02-19T14:29:32Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [March 8, 2021, 6:47pm UTC](https://discourse.itk.org/t/extracting-bounding-box-information-from-an-image/3883/5 "2021-03-08T18:47:53Z")

</div>

Additionally, the [`itk::ImageSpatialObject`](https://itk.org/Doxygen/html/classitk_1_1ImageSpatialObject.html) class can be used to compute the bounding box.
