Page 1 of 1

Conversion from FITS to ARR modifies dynamic range

Posted: 2014-06-09T16:12:25-07:00
by FetterDoubt
I have seen a few other posts about similar problems but not exactly what I'm experiencing and in any case the issue was never resolved.
I'm trying to convert a FITS file to a simple raw array. The conversion works but the dynamic range is serverly modified. BTW, the some thing occurs when converting FITS->FITS.

In the original FITS file the min/max is 4877/55028 - range ~55K. After conversion the min/max is 25898/65535 - range ~40K.
Is there a way to convert without modifying the dyaname range? The FITS file is signed 16-bit with a 32768 offset. Is there a way to tell convert about this?

It appears that IM actually computes it's own dynamic range if I'm reading the -verbose output correctly. Why doesn't IM just read the FITS header and use those values?
  • Image: spFocus.fits
    Format: FITS (Flexible Image Transport System)
    Class: DirectClass
    Geometry: 1024x1024+0+0
    Resolution: 72x72
    Print size: 14.2222x14.2222
    Units: Undefined
    Type: Grayscale
    Base type: Grayscale
    Endianess: MSB
    Colorspace: RGB
    Depth: 16-bit
    Channel depth:
    gray: 16-bit
    Channel statistics:
    gray:
    min: 25898 (0.395178)
    max: 65535 (1)
    mean: 52871.5 (0.806767)
    standard deviation: 5411.11 (0.0825682)
    kurtosis: 5.16194
    skewness: -1.97673
    Histogram:...
    Rendering intent: Undefined
    Interlace: None
    Background color: white
    Border color: rgb(223,223,223)
    Matte color: grey74
    Transparent color: black
    Page geometry: 1024x1024+0+0
    Dispose: Undefined
    Iterations: 0
    Compression: Undefined
    Orientation: Undefined
    Properties:
    date:create: 2014-06-04T12:50:14-10:00
    date:modify: 2014-06-04T09:21:06-10:00
    fits:bitpix: 16 /bits per data value
    fits:bscale: 1.00000 /
    fits:bzero: 32768 /
    fits:extend: T /file may contain extensions
    fits:naxis: 2 /number of axes
    fits:naxis1: 1024 /
    fits:naxis2: 1024 /
    fits:simple: T /image conforms to FITS standard
    signature: d684f6a4951a373adcd5009ad77bc72386872cbd3164b8e36670757574e724fe
    Artifacts:
    verbose: true
    Tainted: False
    Filesize: 2.005mb
    Number pixels: 1mb
    Version: ImageMagick 6.5.4-7 2014-02-10 Q16 OpenMP http://www.imagemagick.org

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2014-06-09T16:39:14-07:00
by fmw42
I know nothing about Fits format. But from the IM formats page, see

FITS RW Flexible Image Transport System To specify a single-precision floating-point format, use -define quantum:format=floating-point. Set the depth to 64 for a double-precision floating-point format.

Perhaps try that?

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2014-06-12T20:40:26-07:00
by FetterDoubt
This is not a valid solution. It changes the depth to 32 bpp.
Even a simple FITS->FITS conversion changes the dynamic range. Why?

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2014-06-12T20:53:16-07:00
by fmw42
Perhaps you should post this to the Bugs forum, if you think there is an error in the IM coding.

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2014-06-12T21:38:20-07:00
by dlemstra
Can you post a link to your file?

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2017-03-25T17:03:16-07:00
by djulik
I have a similar issue.

I "convert- resize" a 2d fits file which has BITPIX = -64 with pixels values (intensities) between -278.245 and 982.9495.
It works well the image looks good but the pixels values are of the order of +/- 2e18 and BITPIX = 64 (positive).
I cannot open that array anymore with python or else, it works with ds9.

Would it be possible to perform a conversion with ImageMagick without changing the BITPIX?
Or to change back the BITPIX?

Thank you in advance,

djulik

Re: Conversion from FITS to ARR modifies dynamic range

Posted: 2017-03-25T17:15:13-07:00
by snibgo
I know nothing about FITS, but I suggest you:

- say what version IM you are using, on what platform
- paste the command or code you used
- paste a link to your input file.