[Insight-users] Reading Analyze files

Luis Ibanez luis . ibanez at kitware . com
Thu, 02 Oct 2003 17:43:39 -0400


Hi Jenny,

PNG is quite a restrictive format.
It only supports "unsigned char" and
"unsigned short" pixel types.

It is very likely that the PNG image
that you got back from the Analyze one
is actually containing the image data
but stored in the range of "unsigned
short" = [ 0:65535]. An image of maximum
intensity = 255 will look solid black
in this range.

Most viewers will not rescale the intensity
range of PNG files when you open them.

Please try the ImageViewer application
available on InsightApplications. You can
use this viewer for checking both the Analyze
image and the PNG image.

(It will also work for DICOM, Meta,VTK, GIPL...)



If you know that your pixel-type fits in 8bits,
make sure that the ImageFileWriter that you use
for saving the PNG image is declared over an image
of "char" or "unsigned char", like

   itk::ImageFileWriter< itk::Image< char, 2 > >

E.g. in

    Insight/Examples/Code/IO/ImageReadWrite.cxx

go to line 87 and replace "short" with "char"



Regards,


   Luis


-------------------------
Jenny Simpson wrote:
> I tried what you suggested with a recent cvs checkout of itk (last night)
> and it didn't work for me.  When I convert the .png to .hdr/.img and then
> .hdr/.img back to .png, my resulting png is always blank.  I tested this
> with Itk v 1.2 and it worked fine, so I know it worked at one point.  It
> was also not working in a checkout I did soon before the release of Itk
> 1.4.  I'm not sure what else to try.  I just used one of the sample brain
> .png images and the exact instructions you gave me.  Any ideas?
> 
> Thanks,
> 
> Jenny Simpson
> Scientific Computing and Imaging Institute
> University of Utah
> 
> 
> On Fri, 29 Aug 2003, Luis Ibanez wrote:
> 
> 
>>Hi Jenny,
>>
>>The Analyze reader are working ok according to the nightly
>>tests in the dashboard. (this is what you will see in ITK 1.4)
>>
>>The simplest test you can do for reading Analyze files is
>>to use the Examples in  Insight/Examples/IO.
>>
>>Try
>>
>>           ImageReadWrite.cxx
>>
>>This simple program expect just an input image filename
>>and an output image filename.
>>
>>ITK will recognize the extension  ".hdr" for analyze.
>>
>>You can do something like convert PNG images in to Analyze
>>by using
>>
>>   ImageReadWrite   Brain.png  Braing.hdr
>>
>>then convert it back to PNG by calling
>>
>>   ImageReadWrite   Brain.hdr  Brain2.png
>>
>>You will find some images in
>>
>>             Insight/Examples/Data
>>
>>
>>Regards,
>>
>>
>>    Luis
>>
>>--------------------------------------------------
>>Jenny Simpson wrote:
>>
>>>Thanks for the earlier help on getting DICOM files read in -- that seems
>>>to be working fine.  I'm working on reading in Analyze files now. I read
>>>that there were some problems with reading Analyze files in Itk 1.2, so I
>>>did a cvs checkout of Itk on 8/26/2003.  What is the correct syntax for
>>>running itkIOTest itkAnalyzeImageIOTest?  Also, what output/results should
>>>I expect to see on a successful run of the test?  I've tried various
>>>things but the output doesn't make sense to me.  Ideally I'd like to find
>>>some sample .hdr and .img files, specify them on the command line of the
>>>test, and get the pixel data and/or an image of the data contained in the
>>>Analyze files.  Is this still under development?  Am I making incorrect
>>>assumptions about what this test is supposed to do?
>>>
>>>Thanks,
>>>
>>>Jenny Simpson
>>>SCI Institute
>>>University of Utah
>>>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk . org
>>>http://www . itk . org/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>
>>
>