feat(core): use image orientation everywhere
Description
This change ensure the image orientation is used to compute positions to/from image to/from world.
Basically, we need to alter the code each time we use the golden formula pos(x mm) = origin(x) + (spacing(x) \* pox(x pixel)) with x the wanted world axis
or use axis aligned bounding boxes.
To help the process and to factorize some code data::image
class have now two functions data::image::image_to_world()
and data::image::world_to_image()
that convert image coordinates from/to world coordinates. They use internally data::image::m_orientation
, data::image::m_origin
and data::image::m_spacing
and they are templated, so you can use any container that holds 3d coordinates, without having to use {x, y, z}
construct to convert from/to Ogre, gml, itk, ...
Notable modified classes / helpers:
- volume_renderer
- ray_tracing_volume_renderer
- scene
- negato3d
- negato2d
- negato2d_camera
- medical_image
- plane
- image_extruder
- resampler
- itk (reader, writer, converter)
- vtk (reader, writer, converter)
- image_center
- propagator
- slice_index_position_editor
- ruler
- shape
- point
Should be done or checked later
- image_converter
- image_properties
- plane_slicer
Breaking change(s)
All code that assumes the image is always aligned with the scene axis, may need to be adapted.
How to test it?
You may use this data: volume_4b_uint8.nii.gz
This is a modified version with this hardcoded orientation:
{
0.0000000, -0.8660254, 0.5000000,
0.5000000, -0.4330127, -0.7500000,
0.8660254, 0.2500000, 0.4330127
}
You can also use data from https://github.com/neurolabusc/niivue-images
- Unit tests
- Everything that uses the modified classes should be tested:
- loading/writing of a dicom/vti/nifti with an arbitrary orientation (although this is unit tested)
- negato
- propagator
- image_extruder
- ...
Related issue(s)
Blocks #904 (closed)