[Insight-users] How to Convert ITK RGB Image to VTK Image

Luis Ibanez luis.ibanez at kitware.com
Sat Jul 10 22:55:48 EDT 2004


Hi John,

Thanks for pointing this out.

We were able to reproduce the problem you reported
and we are looking for a source, but it doesn't seem
to be just a simple bug for GBR. It looks like we
are skipping ByteSwapping in some place where it
must have been done.

.... still looking for the real solution....


Regards,


    Luis


--------------------
John Biddiscombe wrote:

> Go to itkVTKImageExport.txx in Code/BasicFilters
> 
> at line 79 or nearby add the following lines
> 
> else if(typeid(ScalarType) == typeid(itk::RGBPixel<unsigned char>))
> {
>     m_ScalarTypeName = "unsigned char";
> }
> 
> This will now work providing your image type is itk::RGBPixel<unsigned char>
> if you're using itk::RGBPixel<float> or <double>, then add the similar lines
> for those cases (return "float" or "double". It should still work. The
> number of components is computed from
> sizeof(pixeltype)/sizeof(primitivetype), which gives 3 in our case
> (regaredless of which type, providing you get it right).
> 
> This is how I'm converting TIFF images. Except that I've got RGB mixed up
> and I have GBR instead. I'll look at that today and see if the image maper
> is expecting components reversed etc.
> 
> JB
> 
> 
> 
> ----- Original Message ----- 
> From: "Patrick (Peng) Cheng" <peng-cheng at uiowa.edu>
> To: "insight-users" <insight-users at itk.org>
> Sent: Thursday, July 08, 2004 10:34 PM
> Subject: [Insight-users] How to Convert ITK RGB Image to VTK Image
> 
> 
> 
>>Hi,
>>I use the itkImageToVTKImageFilter, but there is an error when I new a
> 
> instance of this filter. What's going wrong?
> 
>>typedef itk::RGBPixel< float > RGBPixelType;
>>typedef itk::Image<RGBPixelType,3> RGBImageType;
>>typedef itk::ImageToVTKImageFilter< RGBImageType > RGB2VTK;
>>RGBImageType::Pointer m_RGBImage = RGBImageType::New();    <-----
>>---------------------------
>>Peng (Patrick) Cheng
>>Biomedical Engineering
>>University of Iowa
>>Tel:(319) 400-7442
>>Email: peng-cheng at uiowa.edu
>>
>>
>>
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users at itk.org
>>http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 





More information about the Insight-users mailing list