How to go from a coordinate in a 3D slicer software to a coordinate on the new STL

8 views (last 30 days)
I was wanting to take a 3D image and use a 3D slicer tool (ITKSNAP, 3D Object Slicer, or any other reccomended software) to obtain a new mesh file.
How could I design a pipeline to go from a coordinate of a specific pixel in a 3D image to identifying the coordinates of the same pixel on a mesh generated from the original 3D image?
Thanks

Answers (1)

Anurag
Anurag on 24 Nov 2023
Hi Andrew,
I understand that you want to generate and identify the coordinates of 3D of pixels on a mesh generated from the original 3D image.
Refer to the pipeline below for doing the same:
  • Acquire your 3D image and use segmentation tools to segment the region of interest containing the structure you are interested in.
  • Generate mesh. In MATLAB you can use “generateMesh” for that.
  • Use the transformation matrix to transform the pixel coordinates from the image space to the mesh space.
Example in MATLAB using NIfTL Header information:
% Load NIfTI image
image = load_nii('path/to/your/image.nii');
% Voxel coordinates
voxel_coords = [i, j, k];
% Apply transformation to get physical world coordinates
world_coords = image.hdr.hist.qform * [voxel_coords, 1]';
In this example, image.hdr.hist.qform is the transformation matrix stored in the NIfTI header.
"World_coords" now represent the physical world coordinates.
Hope this helps!
Regards,
Anurag
Please refer to the below documentation to know more about the “generateMesh” and further readings:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!