IpPic Free Core

From mitk.org
(Redirected from Development/IpPicFreeCore)
Jump to navigation Jump to search

This page documentes the changes in the interface and code structure which were necessary for completely removing the dependancy of the Core module to the IpPic module.

Consequently, the `.pic` data format was replaced by the `.nrrd` data format on the position of the standard MITK data format. In the near future, storing to a `.pic` will be disabled. The loading of `.pic` will be supported longer.

The most affected class is `mitk::Image` since the whole management of the image data was done by the `IpPicDescriptor`.


Changes in mitk::Image

Summary

The art of changes in the Image class is twofold. First, the IpPicDescriptor and all related methods were replaced by new descriptor objects. 
Second, as part of the refactoring, the whole statistics computation was moved into a new object.


New descriptors

The IpPicDescriptor got replaced by two new descriptors:

  • mitk::ImageDescriptor which holds the dimension information for the image and a `std::vector` of descriptors for the image's channels
  • mitk::ChannelDescriptor which holds the essential information for a channel, i.e. its size and pixel type


Image statistics

All members of the `mitk::Image` class related to statistics computation were moved to a new object ImageStatisticsHolder. For temporary backward compatibility, the methods for accessing the statistics like `GetScalarValueMax()` are still available in the interface of mitk::!Image, but are marked as deprecated. Old-style calls like:

<syntaxhighlight lang="cpp"> double scMax = m_Image->GetScalarValueMax(); </syntaxhighlight>

have to be replaced by:

<syntaxhighlight lang="cpp"> double scMax = m_Image->GetStatistics()->GetScalarValueMax(); </syntaxhighlight>


Changes in mitk::PixelType

With IpPic present, the PixelType was forced to hold a member of type `mitkIpPicType_t`. The re-worked PixelType stores the `std::type_info`. Also the creation of a PixelType instance has changed. There are three methods how to instantiate a PixelType object:

Single component pixel types ( i.e. scalar types) can be created like the following `float` type:

<syntaxhighlight lang="cpp"> mitk::PixelType myScalarPType =

 mitk::MakeScalarPixelType< float >();

</syntaxhighlight>

PixelType instances for ITK image types are created like:

<syntaxhighlight lang="cpp"> typedef itk::Image<itk::RGBAPixel<unsigned char>, 3> itkImageType;

mitk::PixelType myPType = mitk::MakePixelType<itkImageType>(); </syntaxhighlight>

And fully customized PixelType instances are created like:

<syntaxhighlight lang="cpp"> mitk::PixelType myCustomPType =

 mitk::MakePixelType<char, YMKType<char>, 3>();

</syntaxhighlight>

There are two public methods for getting the type_info from a PixelType object.

  • `GetPixelTypeId()` returns the type of the whole pixel type
  • `GetTypeId()` returns the type of the component ( i.e. unsigned char for the myPType in the example given above)


Usage of IpPic

Multiple algorithms located in the MitkExt module and also some Bundles still need to have access to the IpPic module. To provide backward compatibility, there are now two new modules

  • IpPicSupport
    • contains all I/O related classes (`Writer`, `Reader`, `IOFactory`) previously located in Core/
  • LegacyAdaptors
    • contains methods for casting between the new image format and an the IpPicDescriptor: `CastToIpPicDescriptor`, `CastToImageDescriptor`
    • all methods in this module are marked as deprecated, including this module will cause the compiler to throw compile warnings (if enabled)
    • further information is available from the nightly generated documentation