[Insight-users] Help ImageReadWrite program
gavinb+xtk at cs.mu.OZ.AU
Wed Jun 9 12:37:56 EDT 2004
On Wed, Jun 09, 2004 at 11:59:35AM -0400, yingli fan wrote:
> Thank you, I use the program example/IO/ImageReadWrite.cxx the image file I
> use is the png file and it is BrainProtonDesitySlice.png I found In the
> example folder.
> I just run
> ./ImageReadWrite BrainProtonDesitySlice.png 1.png
I just tested this and it works just fine. As I mentioned...
> > Second, which program are you using to view the result?
> > It quite possible that you are trying to display a 16-bit data file,
> > where the data all lives in the lower end of the spectrum. Many
> > graphics programs will not rescale the intensity, so the image may
> > appear black even though there is non-zero data.
> > The ImageViewer application (in InsightApplications) can view all
> > supported formats properly, including handling anisotropic data.
If you have ImageMagick installed (a very fine set of tools) you can use the
'identify' command to print out info about the file format. If I run this
with the output of the above command (just as you describe) and I get:
% identify foo.png
foo.png PNG 181x217+0+0 PseudoClass 65536c 16-bit 35kb 0.020u 0:01
The output looks fine with ImageViewer.
If you go back to the code and look at line 87, note that the PixelType is
being set to 'unsigned short'. So regardless of the input data (which
happens to be 8-bit) the File I/O reader will cast the result to a short
(which is 16-bits). This same type is used for the output image, which
explains why the output file is actually a different format (16-bit) than
the original (8-bit) even though they are both PNG. The data is identical,
but the word size has changed.
Gavin Baker Complex Systems Group
http://www.cs.mu.oz.au/~gavinb The University of Melbourne
More information about the Insight-users