16-bit FITS - automatic conversion?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

16-bit FITS - automatic conversion?

Andy Puckett
I have two questions, both related to opening a 16-bit (signed) FITS image:

1. There are no BSCALE or BZERO keywords in the header, but "Show Info..." reveals the calibration
function it claims to be using:  y = -32768.0 + 1.0x.  It also says 'Unit: "gray value"' although I
don't see this anywhere in the header (no BUNIT keyword).  Where is this coming from?  Does
ImageJ automatically convert between signed and unsigned values, despite the lack of a BZERO
keyword?  

2.  On this image, the status bar reveals two different "values" for every pixel.  For example:
          value = 235.00 (33003)
I see that they differ by 32768.  But which of these is the "raw" value that is stored in the FITS
image array, and which is the "calibrated" value?  The calibration function above suggests the
parenthetical value is the raw value, but my boss is telling me otherwise.  (I have opened this file
in SAOImage ds9 and IDL, and the values I get are the smaller ones, which aren't in parentheses
here.  So if those AREN'T the raw values, then all FITS readers must know to make this conversion,
right?)

3.  I'm using ImageProcessor.getPixelValue in my plugin to access these values, recently changed
from getPixel.  The documentation isn't clear on the difference between these two functions.  Does
one return the parenthetical value above, and the other return the other value?

Thanks,
Andy Puckett
University of Alaska Anchorage
Reply | Threaded
Open this post in threaded view
|

Re: 16-bit FITS - automatic conversion?

Wayne Rasband
> I have two questions, both related to opening a 16-bit (signed) FITS
> image:
>
> 1. There are no BSCALE or BZERO keywords in the header, but "Show
> Info..." reveals the calibration
> function it claims to be using:  y = -32768.0 + 1.0x.  It also says
> 'Unit: "gray value"' although I
> don't see this anywhere in the header (no BUNIT keyword).  Where is
> this coming from?  Does
> ImageJ automatically convert between signed and unsigned values,
> despite the lack of a BZERO
> keyword?

ImageJ supports signed 16-bit images by adding 32,768 and then using
the y = -32768 + x calibration function to recover the original signed
values.

>  2.  On this image, the status bar reveals two different "values" for
> every pixel.  For example:
>           value = 235.00 (33003)
> I see that they differ by 32768.  But which of these is the "raw"
> value that is stored in the FITS
> image array, and which is the "calibrated" value?  The calibration
> function above suggests the
> parenthetical value is the raw value, but my boss is telling me
> otherwise.  (I have opened this file
> in SAOImage ds9 and IDL, and the values I get are the smaller ones,
> which aren't in parentheses
> here.  So if those AREN'T the raw values, then all FITS readers must
> know to make this conversion,
> right?)

For signed 16-bit images, the first value is the signed value and the
value in parentheses is the signed value plus 32,368. Otherwise, the
first value is the calibrated value and the value in parentheses is the
raw value.

> 3.  I'm using ImageProcessor.getPixelValue in my plugin to access
> these values, recently changed
> from getPixel.  The documentation isn't clear on the difference
> between these two functions.  Does
> one return the parenthetical value above, and the other return the
> other value?

The getPixelValue(x,y) method returns the calibrated (first) value and
getPixel(x,y) returns the raw value (the one in parenthesis).

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: 16-bit FITS - automatic conversion?

Andy Puckett
In reply to this post by Andy Puckett
Thanks Wayne, I was beginning to realize that this was the case.  However, there is a bug in
getPixelValue(x,y), or at least a bug in my understanding of how to use it.  I am finding that it
incorrectly returns the raw (parenthetical) value, except after I have done a "Show Info..." on the
image.  Then it does what you say it should do, returning the calibrated (first) value.

I have tried to use getCalibrationTable, thinking that this is what "Show Info..." is doing to help
getPixelValue(x,y) along.  However, the resulting float array is null.  Here is what I'm trying, in
ImageJ 1.40a:

        float[] cTable = imageProcessor.getCalibrationTable();
        IJ.error(""+cTable);
        double value = imageProcessor.getPixelValue ( currX, currY );

So what am I doing wrong?

Andy


On Wed, 14 May 2008 17:28:09 -0400, Wayne Rasband <[hidden email]> wrote:

>The getPixelValue(x,y) method returns the calibrated (first) value and
>getPixel(x,y) returns the raw value (the one in parenthesis).
>
>-wayne