[Insight-users] ImageReadExtractWrite!!!

Luis Ibanez luis . ibanez at kitware . com
Wed, 21 May 2003 10:10:07 -0400


Hi Marisa,

This example does not perform extensive error checking.

It naively trusts the user for making reasonable choices.

If you have an image of 512 x 512 pixels and ask for
extracting a region of size 600 x 200, this may accidentaly
work, just because 600x200 =120.000 is less than 512^2.

When we say 'work', this is figurative since the resulting
image will probably have diagonal artifacts typical of
out-of-phase wrapping. The output image will certainly be
unusable.

Your understanding of the parameters is correct, first you
provide the X,Y of the first pixel in the region you want
to extract, then you provide the X,Y size of the region.

-------

About the totaly blank PNG image that you obtain.
Note that many viewers *do not* normalize images for
display. It is a common accident to save 8bits data
into a 16bit image and try to display the image.
The output image looks black in a non-normalizing
viewer since the full dynamic range is 65535 but
probably the highest value in the image is just 255.

Please use a viewer that normalizes images (or at
least has the option to do so). The ImageViewer
application available with InsightApplications is
an example of such a viewer. 'display' in the
ImageMagick tools is another example (but here you
have to explicitly ask for normalization).

You can also use the MinimumMaximumImageCalculator
in order to check the extreme intensity values of
the image before saving it in PNG.




    Luis



---------------------
marisa aurelio wrote:
> Hi U All,
> 
> I'm still having doubts about ImageReadExtractWrite.
> If I understood correctly, when they say that we must call the file saying:
> inputImageFile outputImageFile startX startY sizeX sizeY, they mean:
> 
> - inputImageFile = the name of the file where the image is
> - outputImageFile = the name we want to give to the output file
> - startX = axis X = where we want to start
> - startY = axis X = where we want to start
> - sizeX = the size of the picture we want in the X axis
> - sizeY = the size of the picture we want in the Y axis.
> 
> So, if I have an image with 512x512 I could never say that I want sizeX 
> = 514, for example.
> But I can. Only above a certain value, it gives an error. WHY???
> 
> Also, I'm using a PNG image and, as someone said I must change:
> typedef signed short InputPixelType (still the same)
> typedef signed short OutputPixelType -> typedef unsigned short 
> OutputPixelType;
> 
> I did this, but what I get is a total black image, using:
> - startX = 1
> - startY = 1
> - sizeX = 400
> - sizeY = 400
> 
> Can someone HELP ME!!!
> 
> Thanks in advance
> Marisa