[Insight-users] Image formats

Luis Ibanez luis.ibanez at kitware.com
Tue Sep 14 11:18:39 EDT 2004


Hi Chris,


You can read JPEG files into ITK images declared as
having PixelType = double.


Like for example

  typedef double  PixelType
  typedef itk::Image< PixelType, 2 > ImageType;
  typedef itk::ImageFileReader< ImageType > ReaderType;

When you read a JPEG file containing a "char" (8bits)
image into the ImageType above, the reader will cast
the values into the PixelType (double in this case).

Casting is performed using standard C rules.
Not rescaling is done in that conversion.


You *cannot* write "double" images into JPEG files.
This is simply because JPEG cannot represent pixel values
as "double". If you have an ImageType as above you must
Cast it to a "char" image. It is likely that you also
will have to rescale the intensity values in order to
fit/use the range of the chars.

The typical filter for doing both the casting and the
intensity rescaling is the itk::RescaleIntensityImageFilter.

You will find multiple examples on the use of this filter
in the ITK SoftwareGuide

    http://www.itk.org/ItkSoftwareGuide.pdf

as well as the associated code examples in

       Insight/Examples/Filtering



If you still find any problems, please let us know what
version of ITK you are using, as well as what is your
compiler and operating system.



Regards,


    Luis


--------------------
chris harris wrote:

> Hi,
>      Iam trying to perform some filter operations on Jpeg images but 
> when I read the image as type double it gives me an error message that 
> only unsigned char is supported by Jpeg . If I  read it as only unsigned 
> char type my application performs some float operations on it and I get 
> an error message that Iam trying to do float operations on char. Now I 
> read in the software guide that we can read and write the images in 
> whichever type suited to our application. So what may be the problem? 
> can't we read and write jpeg images as type double?
> Thanks for the help
>  
> 
> 
> Thanks
> Chris harris
> 






More information about the Insight-users mailing list