Page MenuHomePhabricator

PixelType initialization of an Image in mitkItkImageFileReader is wrong
Closed, ResolvedPublic

Description

The PixelType of the image to be read in is created upon the information provided by the itk::ImageIOBase. This does not provide a type_info for the whole pixeltype ( i.e. itk::RGBPixel< T1 > ) but only for the component type.

To have some type_info provided for the method, the ComponentTypeInfo() is used instead.

For this reason, simply enhancing the MITK_ACCESSBYITK_PIXEL_TYPES_SEQ by the composite type ( itk::RGBPixel< T1 > ) will not work, since while iterating through the sequence the PixelType stored in the mitk::Image does not match the composite pixel type.

So what will be needed is a method somewhere in mitk ( possible declared in mitk::PixelType directly in the mitk scope )

const type_info& GetPixelTypeFromITKImageIO( const itk::ImageIOBase::Pointer)

which will return the component type for scalar types and the correct type for composite types, i.e.

IN: itk::ImageIOBase::RGBA --> RETURN: typeid( itk::RGBAPixel< ComponentType > )

Event Timeline

As a proof of concept I have tried following (minimal) changes:

  • enhance the MITK_ACCESSBYITK_PIXEL_TYPES_SEQ by (itk::RGBAPixel< unsigned char>)
  • implement prototype of the GetPixelTypeFromITKImageIO() and pass the return value to the creation of the pixel type in mitk::ItkImageFileReader::GenerateData()
  • use the new type in mitk::ImageWriter::WriteByITK

    // OLD: AccessByItk_1( image, _mitkItkPictureWrite, fileName ); AccessFixedPixelTypeByItk_1( image, _mitkItkPictureWrite, (itk::RGBAPixel<unsigned char>) )

and a 2D RGBA image in PNG format was stored successfully with correct format and also image data.

Added ChangeRequest. Requesting Core_Modification flag.

[30ab25]: Merge branch 'bug-12682-Fix-PixelType-for-RGB_A'

Merged commits:

2012-08-02 11:49:19 Jan Hering [f5feb4]
Fixed macro call


2012-08-01 17:38:45 Jan Hering [cd0e99]
Extended ImageWriter Tests

+ added new tests ( 2D PNG RGB and RGBA images )
+ added short CompareMacro to verify the MetaData of the image that was
written out


2012-08-01 17:37:37 Jan Hering [1796ac]
Adapted WriteByITK to the new macros

  • splitted execution for single-component and composite pixel types

2012-08-01 17:01:29 Jan Hering [a2f549]
Fixed pixeltype creation for ItkImageFileReader


2012-08-01 16:53:07 Jan Hering [23f94f]
Adapted _mitkItkPictureWrite to composite pixel types

+ added new mitkItkPictureWriteComposite method
+ extended the method's instantiation


2012-08-01 16:08:32 Jan Hering [73886a]
Added function transforming itk::ImageIOBase into type_info&


2012-08-01 15:47:57 Jan Hering [62d33c]
Enhancing default values for COMPOSITE list

  • added itk::RGB(A)Pixel types to the COMPOSITE_TYPE list
  • excluded the COMPOSITE_TYPE list from the

MITK_ACCESSBYITK_PIXEL_TYPE_SEQ

[7dc57b]: Merge branch 'bug-12682-Fix-PixelType-CMakeConfig'

Merged commits:

2012-08-02 13:44:42 Jan Hering [4e8afe]
COMP: Enforce setting COMPOSITE_PIXEL_TYPES variable

[adc916]: Merge branch 'bug-12682-Fix-PixelType-MissingTests'

Merged commits:

2012-08-06 13:32:17 Jan Hering [9d09aa]
Re-defining new ImageWriterTests

  • the lines were incidentally removed during merge conflict resolving