Conversion from FITS to ARR modifies dynamic range

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
FetterDoubt
Posts: 2
Joined: 2014-06-09T15:19:16-07:00
Authentication code: 6789

Conversion from FITS to ARR modifies dynamic range

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Conversion from FITS to ARR modifies dynamic range

Post 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?
FetterDoubt
Posts: 2
Joined: 2014-06-09T15:19:16-07:00
Authentication code: 6789

Re: Conversion from FITS to ARR modifies dynamic range

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Conversion from FITS to ARR modifies dynamic range

Post by fmw42 »

Perhaps you should post this to the Bugs forum, if you think there is an error in the IM coding.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Conversion from FITS to ARR modifies dynamic range

Post by dlemstra »

Can you post a link to your file?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
djulik
Posts: 1
Joined: 2017-03-25T16:50:27-07:00
Authentication code: 1151

Re: Conversion from FITS to ARR modifies dynamic range

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Conversion from FITS to ARR modifies dynamic range

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply