Author Topic: 8 bit FITS images  (Read 3150 times)

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
8 bit FITS images
« on: 2016 December 20 10:53:57 »
When I open a FITS image with BITPIX=8, the values are treated as 16 bit numbers instead of 8 bit numbers.  For instance, if I have an image where all the pixels are 64 then PI displays them as 16448.  It should be 64.

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: 8 bit FITS images
« Reply #1 on: 2016 December 20 12:00:33 »
Readouts are independent to the native bit depth. Set the readout options to 8bits, and it will read 64.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
Re: 8 bit FITS images
« Reply #2 on: 2016 December 20 23:35:51 »
I'm surprised by that.  I thought readout was how a pixel value was displayed or formatted in internal memory, not how it was input from the FITS file.  I thought BITPIX defined the reading of the pixel and therefore the pixel value when it was loaded into the internal format (e.g. 64 bit floating point).  If BITPIX indicates 8 bit then the pixel value is 64, no matter how it is displayed (e.g., integer, floating point, etc).

But from your reply, Readout is exactly that "Read" "out", it defines how the FITS file is 'read' and displayed 'out', which means this can override the BITPIX setting.  Is that correct?

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: 8 bit FITS images
« Reply #3 on: 2016 December 21 10:50:33 »
No. PI's readouts work at a much higher level. Its only a way to represent the values for the user. As such, the user may define whatever range he wants. It does not change the pixel values themselves, just how they are displayed.
Internally, at a very low level, they always keep the native range. At a medium level (where the algorithms work in the PCL... the processes that make all the magic) they are all translated into the normalized range, and treated as floating points. The PCL itself adjust all the ranges to the proper native bit depth.

So, think that the readouts are something like the Screen Transfer Function. It is just a representation of the data. Not the true value itself (although it can be if the native and the readout ranges match). And, over that, every process in PixInsight will work in the normalized range, so even when you have an integer image, you have to use floating points values in the 0 to 1 range to set the parameters (for example in the histogram or curves).
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline CraigNZ

  • PixInsight Enthusiast
  • **
  • Posts: 94
Re: 8 bit FITS images
« Reply #4 on: 2016 December 21 11:47:56 »
If the pixel values are maintained at the low level and only 'displayed' by readout option, then shouldn't the raw value be 64 and when displayed, regardless of the readout option, it should always show 64?

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: 8 bit FITS images
« Reply #5 on: 2016 December 22 07:15:37 »
No, because in PixInsight 0 stands for black and the maximum value for the given bit depth is white. 64 in 8bits is a different gray level than in 16bits. Much of PI's philosophy is oriented to understand image files as "picture containers", not "data containers". Hence, for displaying purposes, this idea of black to white scale takes more relevancy. Also, the same happens with the process' parameters; everything is handled in the normalized range (from 0 to 1), to avoid confusions and dirty coding practices.
If you want to read the true "raw" value, just make sure to set the readout options to the same bitdepth as the image file.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com