Page 1 of 1

FITS BZERO incorrect header value

Posted: 2018-11-24T06:54:19-07:00
by Gajowy
Hi,
I'm using Imagick library for PHP (ImageMagick 6.9.3-7 Q16 x64 2016-03-27).
I noticed that FITS files saved by the library have a BZERO key value set to 32767.5, while the true value is 32768 (comparing raw bytes and FITS bytes).
According to convention:
true_value = BZERO + BSCALE x array_value
BSCALE is usually 1, so it's even impossible to express true integer value with a offset of 32767.5.
Do you know how to workaround this issue? I could replace header values simply replacing it with 32768, however I have no idea how it would impact further internal image calculations (substarcting, composite etc).

Kind Regards,
Gajowy

Re: FITS BZERO incorrect header value

Posted: 2018-11-24T16:58:33-07:00
by magick
Try the latest release of ImageMagick, 6.9.10-14. It will likely resolve the problem. If not, let us know and we will investigate further.

Re: FITS BZERO incorrect header value

Posted: 2018-11-24T18:34:52-07:00
by Gajowy
It's exactly the same:

SIMPLE = T
BITPIX = 16
NAXIS = 2
NAXIS1 = 1936
NAXIS2 = 1096
BSCALE = 1
BZERO = 32767.5
DATAMAX = 65535
DATAMIN = 0
HISTORY e:\Program Files\ImageMagick-6.9.10-Q16\\index.html
END

Kindly ask for solution.
Regards,
Gajowy

Re: FITS BZERO incorrect header value

Posted: 2018-11-24T19:35:03-07:00
by magick
Can you post a link to a sample image and the command you use to return a FITS file with a BZERO of 32767.5? Once we can reproduce the problem, we will have a fix within just a few days.

Re: FITS BZERO incorrect header value

Posted: 2018-11-26T06:12:02-07:00
by Gajowy
Simplest code below. You can use any input file, eg. the one from Imagick set.

Code: Select all

<?php
$im= new Imagick('rose.png');
$im->setFormat('FITS');
$im->setImageDepth(16);
$im->writeImage('rose.fit');
$im->destroy();
?>

Re: FITS BZERO incorrect header value

Posted: 2018-11-26T17:38:03-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

Re: FITS BZERO incorrect header value

Posted: 2018-11-26T23:04:02-07:00
by Gajowy
Thank you in advance!

Gajowy