Fits image data changed by crop

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Fits image data changed by crop

Post by fmw42 »

IM 6.6.5.4 Q16 (HDRI) Mac OSX Tiger

I have a fits image that I cropped. Before the crop the dynamic range was 0 to 65533. After the crop (to remove black areas) and make it square, the dynamic range (and also the fits properties)) were changed and the data has less contrast. This does not happen when I crop the image in another tool (GraphicConverter on the Mac)

Here is the original file:
http://www.fmwconcepts.com/misc_tests/f ... _st250.fit

Here is the IM cropped file:
http://www.fmwconcepts.com/misc_tests/f ... 50_sub.fit


Here is the GC cropped file:
http://www.fmwconcepts.com/misc_tests/f ... c_crop.fit


Here are the verbose info. Note the red highlighted areas.


Original file:

Image: Jupiter_R_st250.fit
Format: FITS (Flexible Image Transport System)
Class: DirectClass
Geometry: 1387x1035+0+0
Resolution: 72x72
Print size: 19.2639x14.375
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: MSB
Colorspace: RGB
Depth: 32/16-bit
Channel depth:
gray: 16-bit
Channel statistics:
Gray:
min: 0 (0)
max: 65535 (1)
mean: 14290 (0.218051)
standard deviation: 18341.1 (0.279867)
kurtosis: -0.954094
skewness: 0.825125
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 1387x1035+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2010-10-27T14:37:14-07:00
date:modify: 2010-10-26T16:05:41-07:00
fits:bitpix: -32 /bits per data value
fits:extend: T /file may contain extensions
fits:naxis: 2 /number of axes
fits:naxis1: 1387 /
fits:naxis2: 1035 /
fits:simple: T /image conforms to FITS standard
signature: fcaa13e30a1257d842d8d4f819bdc31f587a5ad15ee4a15aa81681721ab8de31
Artifacts:
verbose: true
Tainted: False
Filesize: 5.746MBB
Number pixels: 1.436MB
Pixels per second: 2.051MB
User time: 0.670u
Elapsed time: 0:01.700
Version: ImageMagick 6.6.5-5 2010-10-31 Q16 http://www.imagemagick.org


IM cropped file:

Image: Jupiter_R_st250_sub.fit
Format: FITS (Flexible Image Transport System)
Class: DirectClass
Geometry: 1034x1034+0+0
Resolution: 72x72
Print size: 14.3611x14.3611
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: MSB
Colorspace: RGB
Depth: 32/16-bit
Channel depth:
gray: 16-bit
Channel statistics:
Gray:
min: 16449.4 (0.251002)
max: 44510 (0.679179)
mean: 25934.8 (0.39574)
standard deviation: 9499.13 (0.144948)
kurtosis: -1.46911
skewness: 0.359113
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 1034x1034+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2010-10-27T14:41:02-07:00
date:modify: 2010-10-27T14:41:02-07:00
fits:bitpix: 32
fits:bscale: 1.000000E+00 <-------????
fits:bzero: 4.294967E+09 <-------????
fits:datamax: 4.294967E+09 <-------????
fits:datamin: 0.000000E+00 <-------????
fits:history: ImageMagick 6.6.5-4 2010-10-25 Q16 http://www.imagemagick.org
fits:naxis: 2
fits:naxis1: 1034
fits:naxis2: 1034
fits:simple: T

signature: e17444f0a8f74d68c52b518f1cc27504be4cd2f09f43ceb1a5b97c6dc6d09030
Artifacts:
verbose: true
Tainted: False
Filesize: 4.28MBB
Number pixels: 1.069MB
Pixels per second: 3.687MB
User time: 0.280u
Elapsed time: 0:01.290
Version: ImageMagick 6.6.5-5 2010-10-31 Q16 http://www.imagemagick.org
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Fits image data changed by crop

Post by anthony »

I withdraw my previous post.

It does look like something is wrong with the IM cropped FITS.


I would however suggest you work directly with PNG->FITS rather than FITS->FITS
the simpler you can make the problem the better.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fits image data changed by crop

Post by fmw42 »

anthony wrote:I withdraw my previous post.

It does look like something is wrong with the IM cropped FITS.


I would however suggest you work directly with PNG->FITS rather than FITS->FITS
the simpler you can make the problem the better.

My original was Fits. I tried cropping to png and got similar but different results. However, it does look like fits to png convert with no cropping works OK. Perhaps once in PNG I can crop that.

But I am trying to keep the fits file as input to some FFT processing that I need to duplicate. So it is hard to know if that is working if I change the format.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fits image data changed by crop

Post by fmw42 »

I took a quick look at http://fits.gsfc.nasa.gov/fits_primer.html which says that FITS format supports floating point values. Thus it may be an issue of negative values in my image that IM is not honoring properly even though I am in HDRI mode.

see also version 3 of the standard for FITS at http://fits.gsfc.nasa.gov/fits_standard.html
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Fits image data changed by crop

Post by magick »

Did you add -define quantum:format=floating-point to your command line? If not, 32 and 64-bit FITS images are saved as unsigned ints.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fits image data changed by crop

Post by fmw42 »

magick wrote:Did you add -define quantum:format=floating-point to your command line? If not, 32 and 64-bit FITS images are saved as unsigned ints.
I tried that but it gives the same odd results as above.

If I convert the whole file to PNG, then crop, I don't get the odd result. Not sure what this means? The conversion to PNG may clip the values or stretch the values to proper Q16 range, so then there is no further issue.

My guess is that the FITS file has negative values and positive values perhaps outside the range 0-65535. When it is cropped, the real min ( and max values ) are changed. But identify -verbose, does not indicate that there are negative values in the original. However, my GraphicConvert seems to imply they are min=-4042.72 and max=69324.51

After the crop, it shows rediculously negative and positive values for the min and max. So I am not sure what to make of that either, unless IM is doing something very odd.
Post Reply