milk-org / milk

Modular Image processing Library toolKit (milk) :telescope:
https://milk-org.github.io/milk/
5 stars 10 forks source link

saveFITS does fail for uint8_t images #16

Closed jbOhland93 closed 1 year ago

jbOhland93 commented 1 year ago

Saving an image in shared memory to a fits file does not work anymore for UI8 images. Here's what happens:

This does not happen for uint16_t and float images - I did not try other ones.

milk-branch: dev (commit 29f799d42126fac113d7bbebd9d45bb291f2820c) ImageStreamIO-branch: dev (commit 2ab382dd4bb774f7aaa9ef67385278e3b53ebca2)

DasVinch commented 1 year ago

Noted.

Seems that the int8/uint8 saveFITS is quite broken.

DasVinch commented 1 year ago

Find the odd one out (from the cfitsIO manual)...

The following 4 data type codes are also supported by CFITSIO:
#define SBYTE_IMG 10
/* 8-bit signed integers, equivalent to */
/* BITPIX = 8, BSCALE = 1, BZERO = -128 */
#define USHORT_IMG 20 /* 16-bit unsigned integers, equivalent to */
/* BITPIX = 16, BSCALE = 1, BZERO = 32768 */
#define ULONG_IMG
40 /* 32-bit unsigned integers, equivalent to */
/* BITPIX = 32, BSCALE = 1, BZERO = 2147483648 */

I'm writing a PR.

jbOhland93 commented 1 year ago

Now that's funky! Is the BZERO of the 8-bit signed int set to -128 rather than 0 because the unsigned counterpart is used more frequently and having a zero is more environmentally friendly? Feels like it's worth the confusion.