# Get oriented bounding boxes for each segment

**URL:** <https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [September 21, 2021, 10:58pm UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796 "2021-09-21T22:58:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 21, 2021, 10:58pm UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796/1 "2021-09-21T22:58:14Z")

</div>

是不是可以开发自动boundingbox功能呢?如果能够 oriented bounding _box_ 就太好了…

> Is it possible to develop an automatic boundingbox function? It would be great if it could be oriented bounding _box_…

---

<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 22, 2021, 12:38am UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796/2 "2021-09-22T00:38:30Z")

</div>

This feature is already available in Segment Statistics module. See complete example [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-size-position-and-orientation-of-each-segment).

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/3/63d764c1f909a0860b9dd3284818f95b5d9abde9.jpeg)

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [September 22, 2021, 12:42am UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796/3 "2021-09-22T00:42:39Z")

</div>

That is Great! 👍 Thanks

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [July 18, 2022, 12:09pm UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796/4 "2022-07-18T12:09:02Z")

</div>

我用这个示例做了pedicle的obb，又用以下代码crop volume：

> I used this example [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-size-position-and-orientation-of-each-segment)to make the obb of the pedicle, and also used the following code to crop the volume:

`cropLogic = slicer.modules.cropvolume.logic() crop_module = slicer.vtkMRMLCropVolumeParametersNode() crop_module.SetROINodeID(roi.GetID()) crop_module.SetInputVolumeNodeID(volume.GetID()) crop_module.SetVoxelBased(True) cropLogic.Apply(crop_module) `

却得到了下面我不想要的结果（注意：红色的是得到的obb）：

> But I get the following result that I don’t want(Note: the red one is the obb):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/c/6c693a5f87890110d6566734f3cc04203e350b68.png)

> What’s wrong?

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [July 18, 2022, 12:45pm UTC](https://discourse.slicer.org/t/get-oriented-bounding-boxes-for-each-segment/19796/5 "2022-07-18T12:45:19Z")

</div>

好吧，解决了。。。

> Well, I’ve solved. . .

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/8/48e3fd7f51089a292529418c9c1126dd023238e0.png)
