# Do you know how to convert real world coordination to image coordination?

**URL:** <https://discourse.slicer.org/t/do-you-know-how-to-convert-real-world-coordination-to-image-coordination/41748>\
**Category:** Development\
**Tags:** python\
**Created:** [February 17, 2025, 8:25pm UTC](https://discourse.slicer.org/t/do-you-know-how-to-convert-real-world-coordination-to-image-coordination/41748 "2025-02-17T20:25:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_Prince](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chris_prince/32/79478_2.png) [@chris\_Prince](https://discourse.slicer.org/u/chris_Prince)\
**Post date:** [February 17, 2025, 8:25pm UTC](https://discourse.slicer.org/t/do-you-know-how-to-convert-real-world-coordination-to-image-coordination/41748/1 "2025-02-17T20:25:45Z")

</div>

In data probe. we can see the image coordination, do you know or having script to know how it convert the real world coordination to image coordination?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f1fd79943581c8ac01ddf67de07b58351c9787b0.jpeg)  
My task is to get the boundingbox in 2D slicer from 3D segmentation. so e.g I get a segmentation bounding box coordination like: “box”: [  
[  
68.03462219238281,  
105.50535583496094,  
-159.68885803222656,  
21.68463134765625,  
21.6978759765625,  
17.426727294921875  
], but I don’t know how to map them back to the image coordination.  
I find a guild in 3D visulization: [tutorials/detection/luna16\_visualization at main · Project-MONAI/tutorials · GitHub](https://github.com/Project-MONAI/tutorials/tree/main/detection/luna16_visualization) so then I convert a .obj file like: for one boundingbox, the 8 corner coordination(cube) like :v 78.87693786621094 116.35429382324219 -168.4022216796875  
v 78.87693786621094 94.65641784667969 -168.4022216796875  
v 57.19230651855469 94.65641784667969 -168.4022216796875  
v 57.19230651855469 116.35429382324219 -168.4022216796875  
v 78.87693786621094 116.35429382324219 -150.97549438476562  
v 78.87693786621094 94.65641784667969 -150.97549438476562  
v 57.19230651855469 94.65641784667969 -150.97549438476562  
v 57.19230651855469 116.35429382324219 -150.97549438476562 and the nii.gz original file attrubute like this:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/11e150f821979954e5aeb68a82678e765fa7fd03.png)  
However, I use  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/5/e58e75ab7c4b91973a63df3aafa8fb2b6a9d3146.png)  
I calculated , in Z -ray. it works, the bounding box contain 14 slicer which same to :  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/0/f09b5ed9d0dd8b00013e0869a651c0cbd7085916.png)  
but, X,Y are wrong. however I find that in monai 3D slicer data probe. the conversion is correct. so I wnat to know how it convert?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [February 17, 2025, 9:35pm UTC](https://discourse.slicer.org/t/do-you-know-how-to-convert-real-world-coordination-to-image-coordination/41748/2 "2025-02-17T21:35:35Z")

</div>

You don’t need to do these calculations yourself. There are lots of example in the script repository for going between screen coordinates, world coordinates, and image index coordinates.

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#get-volume-voxel-coordinates-from-markup-control-point-ras-coordinates](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-volume-voxel-coordinates-from-markup-control-point-ras-coordinates)
