[Insight-users] Managing conversion of pixel types during file read

Zachary Pincus zpincus at stanford.edu
Thu, 15 Apr 2004 14:43:48 -0700


Luis,

Aah, there is the trick -- I never thought to check the ImageIO object 
(as opposed to the ImageFileReader object) for the ability to query the 
original pixel type. Thanks! Of course, now that I think on how image 
file reading is implemented, this makes perfect sense.

So yes, reading images in as floats and then doing the rescaling is a 
perfect solution (and the one I had originally planned on before I 
realized that I didn't know how to get the original bit depth, which I 
now do!).

Thank you for your time,

Zach


> Note that you can query the ImageFileReader in order to get the
> "Original" pixel type of the image file.  This must be done
> after you call Update() in the ImageFileReader, since previous
> to that, there may not be any ImageIO object associated with
> the ImageFileReader.
>
> You could invoke the:
>
>       reader->GetImageIO()->GetPixelType()
>
> For the signature of the GetPixelType() method please look
> at the documentation of the ImageIOBase class
>
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1ImageIOBase.html