[Insight-users] RGB->unsigned char

Luis Ibanez luis.ibanez at kitware.com
Fri Apr 3 11:46:16 EDT 2009


Hi Fernando,

The RescaleIntensityFilter will not work on an image of
multiple components (e.g. not in an RGB image).

Do you really need to manage color images ?

or, are you converting the color images to grayscale anyways ?


Most DICOM images will be in grayscale (a single component
per pixel).

If you are converting the images to grayscale, then simply
read them with an ImageType that uses a scalar pixel type
(signed short is probably the best choice, unless you are
dealing with fMRI and or PET).


    Regards,


        Luis



----------------------------
Fernando López Mir wrote:
> 
> I have a problem, because I have a imagetype like a RGB ImageType
> 
>  
> 
> typedef itk::RGBPixel< signed short >      PixelType;
> 
> typedef itk::Image< PixelType, Dimension >  ImageType;
> 
> .
> 
> .
> 
> .
> 
> And I need rescale the image with the property:
> 
>  
> 
> .
> 
> .
> 
> .
> 
> typedef itk::RescaleIntensityImageFilter<ImageType,ImageType > FilterType;
> 
> filter->SetOutputMinimum( 0 );
> 
> filter->SetOutputMaximum( 255 );
> 
> .
> 
> .
> 
> .
> 
>  
> 
> The error is
> 
>  
> 
> error C2664: 
> 'itk::RescaleIntensityImageFilter<TInputImage,TOutputImage>::SetOutputMinimum' 
> : it’s not possible cast the parameter 1 'int' at 'const 
> itk::RGBPixel<TComponent>'
> 
> 2>        with
> 
> 2>        [
> 
> 2>            TInputImage=Medicalsegmentation::ImageType,
> 
> 2>            TOutputImage=Medicalsegmentation::ImageType
> 
> 2>        ]
> 
> 2>        and
> 
> 2>        [
> 
> 2>            TComponent=short
> 
> 2>        ]
> 
>  
> 
> In general I make this because I need read normal images(RGB, JPG, 
> TIFF…), and Dicoms and I need Rescale the dicoms images to [0,255].
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list