# How to obtain Coordinates of the Bounding Box

**URL:** <https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553>\
**Category:** Support\
**Created:** [September 7, 2021, 7:39pm UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553 "2021-09-07T19:39:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rituraj\_Dutta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rituraj_dutta/32/12274_2.png) [@Rituraj\_Dutta](https://discourse.slicer.org/u/Rituraj_Dutta)\
**Post date:** [September 7, 2021, 7:39pm UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/1 "2021-09-07T19:39:26Z")

</div>

I have generated a bounding box (cuboid) for the liver in 3d Slicer using the ROI tool. How can I get the coordinates of the cuboid ?

 ![3d slicer](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/4/d4681c5c35a45c55f3197abc967a44c03346eb7b.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 8, 2021, 4:15am UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/2 "2021-09-08T04:15:40Z")

</div>

You can use the `GetBounds` method of the markups ROI (or the legacy annotation ROI) node:

```auto
>>> import numpy as np
>>> bounds = np.zeros(6)
>>> getNode('R').GetBounds(bounds)
>>> bounds
array([-30.14435768, 79.05784416,
-20.47541332, 40.95082569,
-54.60110092, 54.60110092])

```

The returned values are R min, R max, A min, A max, S min, S max.

---

<div class="post-metadata">

**Author:** ![Rituraj\_Dutta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rituraj_dutta/32/12274_2.png) [@Rituraj\_Dutta](https://discourse.slicer.org/u/Rituraj_Dutta)\
**Post date:** [September 8, 2021, 8:46am UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/3 "2021-09-08T08:46:49Z")

</div>

Thanks for the answer but sorry to say I’m new to 3d slicer so how can I implement this script along with 3d slicer. Like do I need to import some packages or we can run this code directly on 3d slicer ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 8, 2021, 1:55pm UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/4 "2021-09-08T13:55:40Z")

</div>

You can run this code as is, in Slicer’s Python console. To get started with Python scripting in Slicer, check out the [developer tutorials](https://slicer.readthedocs.io/en/latest/developer_guide/api.html#tutorials).

---

<div class="post-metadata">

**Author:** ![Rituraj\_Dutta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rituraj_dutta/32/12274_2.png) [@Rituraj\_Dutta](https://discourse.slicer.org/u/Rituraj_Dutta)\
**Post date:** [September 8, 2021, 2:07pm UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/5 "2021-09-08T14:07:46Z")

</div>

Also one more thing the no. of coordinates should be 8 equal to the number of edges. But here’s it’s 6.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 8, 2021, 2:16pm UTC](https://discourse.slicer.org/t/how-to-obtain-coordinates-of-the-bounding-box/19553/6 "2021-09-08T14:16:20Z")

</div>

The returned values are R min, R max, A min, A max, S min, S max: 3 axes \* 2 bounds = 6.
