Page MenuHomePhabricator

Clarify and rethink MITK to ITK image conversion and vice versa
Closed, WontfixPublic

Description

Currently, there are several high-level methods for converting MITK images to and from ITK images, with different semantics. The aim of this bug report is to consolidate the conversion methods and research an improved memory management mechanism which may be allows to reduce the number of conversion methods.

Methods for ITK --> MITK conversion

This always copies ITK memory:

template<ItkOutputImageType>
void CastToMitkImage(const itk::SmartPointer<ItkOutputImageType>&, mitk::Image::Pointer&)

This takes ownership of the ITK image memory:

template <typename ItkOutputImageType>
Image::Pointer GrabItkImageMemory(itk::SmartPointer<ItkOutputImageType>& itkimage, mitk::Image* mitkImage = NULL, const Geometry3D* geometry = NULL, bool update = true)

This references, but doesn't manage the memory pointed to by the ITK image:

template <typename ItkOutputImageType>
Image::Pointer ImportItkImage(const itk::SmartPointer<ItkOutputImageType>& itkimage, const Geometry3D* geometry = NULL, bool update = true)

Methods for MITK --> ITK conversion

This method references MITK image memory, but doesn't manage it (used by the AccessByItk macros):

template<typename TPixel, unsigned int VDimension>
typename itk::Image<TPixel, VDimension>::Pointer ImageToItkImage(mitk::Image* mitkImage)

This method references the MITK image memory (but doesn't manage it) if the ITK image pixel type matches the MITK image type, otherwise it casts the pixel types by copying memory (uses the above method internally via AccessByItk):

template <typename ItkOutputImageType>
void CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer<ItkOutputImageType>& itkOutputImage)

Event Timeline

kislinsk lowered the priority of this task from High to Low.Dec 16 2016, 10:48 AM
kislinsk edited projects, added MITK; removed MITK (2016-11).
kislinsk claimed this task.
kislinsk added a project: Auto-closed.
kislinsk added a subscriber: kislinsk.

Hi there! 🙂

This task was auto-closed according to our Task Lifecycle Management.
Please follow this link for more information and don't forget that you are encouraged to reasonable re-open tasks to revive them. 🚑

Best wishes,
The MITK devs

kislinsk removed kislinsk as the assignee of this task.May 26 2020, 12:05 PM
kislinsk removed a subscriber: kislinsk.