Hi Heike (and Daniel),

I have improved the support the handling of non-scalar images (as e.g. 
RGB images) in MITK with svn rev 14885. This fixes the problem that 
AccessByItk/AccessTwoImagesFixedDimensionByItk did not recognize the 
image as RGB. Unfortunately, they will not do anything (except issuing a 
warning) for RGB images. This is because many algorithms do not support 
RGB images, including many itk registration methods.

The images that you used are 8 bit, but have a color palette (which is 
of course nonesense for grayvalue images). The itk-image-io for png 
(which is used by MITK) has the following code:
itk::PNGImageIO::Read:
  // convert palettes to RGB
  if (colorType == PNG_COLOR_TYPE_PALETTE)
    {
    png_set_palette_to_rgb(png_ptr);
    }

Thus, all png images with a palette are converted to RGB images.

So the solution still stays the same: change the image file, e.g. by 
removing the palette. Maybe ask the ITK people to put the changed file 
in their repository.

Best regards,

Ivo


Stein Daniel wrote:
> Hi Heike,
>
> this is because of a bug within the casts from MITK images to ITK images. The 
> caster cannot handle RGB *.png images, which is the fact for some of the ITK 
> example images. We already have a bug for this in our internal bug tracker. A 
> solution in your case is to change the color depth from RGB to gray values 
> and save and use the "new" images.
>
>   
> Regards,
> Daniel
>
> ---
>
> Dipl.-Inform. Med. Daniel Stein
> German Cancer Research Center
> Div. Medical and Biological Informatics
> Im Neuenheimer Feld 280
> D-69120 Heidelberg, Germany
> Phone:  (+49) 6221/42-3547
> Fax:    (+49) 6221/42-2345
> http://www.dkfz-heidelberg.de/de/mbi/
> Homepage: http://www.dkfz-heidelberg.de/de/mbi/people/Daniel_Stein.html
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Heike Moll
> Gesendet: Donnerstag, 24. Juli 2008 12:57
> An: [email protected]
> Betreff: [mitk-users] Problem with the adapter class
>
> Hi all,
>
> I have a problem with the adapter classes.
>
> I import two images with the mitk application and I register them with ITK 
> (like in Insight/Examples/Registration/ImageRegistration14.cxx).
>
> It works as long as the registration process only has to shift the picture 
> but if a rotation is involved it gave bad results. To check my code I 
> imported the same images with the itk imagereader and register them. This 
> works without problems.
>
> I convert the mitk images with the adapter AccessTwoImagesFixedDimensionByItk.
>
> Can anyone help me to solve my problem ?
>
> /////////////////////////  Code //////////////////////////////////////
>
> const mitk::DataTreeNode* FixedImageNode = 
> m_fixedDataTreeFilter->GetSelectedItem()->GetNode();
>   //get the data
>   if (!FixedImageNode->GetData())
>   {
>     // Nothing selected. Inform the user and return
>     WARNING_EmptyImageNode();
>     return false;
>   }
>
>   //now check the moving image
>   const mitk::DataTreeNode* MovingImageNode = 
> m_movingDataTreeFilter->GetSelectedItem()->GetNode();
>   if (!MovingImageNode->GetData())
>   {
>     // Nothing selected. Inform the user and return
>     WARNING_EmptyImageNode();
>     return false;
>   }
>
>   // here we have everything valid
>   mitk::BaseData* imageData_f = FixedImageNode->GetData();
>   mitk::BaseData* imageData_m = MovingImageNode->GetData();
>
>   //test if this data item is really an image
>   mitk::Image* image_f = dynamic_cast<mitk::Image*>( imageData_f );
>   mitk::Image* image_m = dynamic_cast<mitk::Image*>( imageData_m );
>
>   if(image_f->GetDimension() != image_m->GetDimension()) return false;
>   const int dim = image_f->GetDimension();
>
>   if (image_f && image_m && (dim == 2)){
>     AccessTwoImagesFixedDimensionByItk( image_f, image_m, 
> itkNormalizedMutualInformation2D, 2 );
>   }
>   else{
>     AccessTwoImagesFixedDimensionByItk( image_f, image_m, 
> itkNormalizedMutualInformation3D, 3 );
>   }
>
> template <typename TPixel_f, typename TPixel_m, unsigned int 
> VImageDimension_f, unsigned int VImageDimension_m>
> void 
> NormalizedMutualInformationRegistration::itkNormalizedMutualInformation2D( 
> itk::Image< TPixel_f, VImageDimension_f >* itkImage_f, itk::Image< TPixel_m, 
> VImageDimension_m >* itkImage_m)
> {
>   typedef itk::Image< TPixel_f, VImageDimension_f > mitkFixedImageType;
>   typedef itk::Image< TPixel_m, VImageDimension_m > mitkMovingImageType;
>
>   typedef double PixelType;
>   typedef unsigned char OutputPixelType;
>   const unsigned int Dimension = 2;
>
>   typedef itk::Image< PixelType, VImageDimension_f > ImageType;
>   typedef itk::Image< PixelType, Dimension >  FixedImageType;
>   typedef itk::Image< PixelType, Dimension >  MovingImageType;
>
>   typedef itk::ImageFileReader< FixedImageType  > FixedImageReaderType;
>   typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
>
>   typename FixedImageReaderType::Pointer  fixedImageReader  = 
> FixedImageReaderType::New();
>   typename MovingImageReaderType::Pointer movingImageReader = 
> MovingImageReaderType::New();
>
>   fixedImageReader->SetFileName( "....png" );
>   movingImageReader->SetFileName( "....png" );
>
>   fixedImageReader->Update();
>   movingImageReader->Update();
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> mitk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mitk-users
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> mitk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mitk-users
>   




-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to