Author Topic: ImageCalibration of cr2 outputs black integer fits  (Read 3108 times)

Offline rudohor

  • Newcomer
  • Posts: 2
ImageCalibration of cr2 outputs black integer fits
« on: 2014 July 09 07:01:51 »
Hello,

ImageCalibration, when given raw canon cr2 files to calibrate and sample format is 16 or 32 bit integer fits, outputs a calibrated fits file containing total blackness.
The same process with sample format 32/64 bit float fits gives correct output. The same process calibrating fits input files instead of raw gives correct output.
The black fits inspected in a text editor shows meaningfully looking fits headers and nonzero data resembling a bayer matrix - every fourth word having similar value (my raw format preferences are set to no debayering, monochrome).

16bit seems to me enough to store calibrated 14bit images, 32bit float is probably overkill. Impact on speed and disk usage is considerable. Having not enough disk to process all files at once is quite a nuisance.

I am PixInsight newbie and maybe doing something wrong.

Thank you.

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: ImageCalibration of cr2 outputs black integer fits
« Reply #1 on: 2014 July 11 11:09:05 »
Quote
16bit seems to me enough to store calibrated 14bit images, 32bit float is probably overkill.

The 32-bit floating point format is necessary to store calibrated images correctly. A calibrated image is no longer raw data, but a matrix of real numbers that needs to be stored as floating point data.

I'll investigate this issue with integer formats. However, the options to store calibrated frames as integer data types will probably be removed in a future version of the ImageCalibration tool.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline rudohor

  • Newcomer
  • Posts: 2
Re: ImageCalibration of cr2 outputs black integer fits
« Reply #2 on: 2014 July 14 08:50:33 »
Thanks, I will need a bigger SSD then. I did not realize that averaging 130 images adds another 7 bits of precision. You are right, total malfunction is much better in this situation than stealthy data loss.

I wrongly believed it should work because I scrolled through the source code in PCL (after unsuccessfully looking for some documentation on how PixInsight handles precision) and found this in PCL/src/modules/processes/ImageCalibration/ImageCalibrationInstance.cpp:
Code: [Select]
   if ( options.ieeefpSampleFormat )
      switch ( options.bitsPerSample )
      {
      case 32 : canStore = outputFormat.CanStoreFloat(); break;
      case 64 : canStore = outputFormat.CanStoreDouble(); break;
      }
   else
      switch ( options.bitsPerSample )
      {
      case 16 : canStore = outputFormat.CanStore16Bit(); break;
      case 32 : canStore = outputFormat.CanStore32Bit(); break;
      case 64 : canStore = outputFormat.CanStore64Bit(); break;
      }
  if ( !canStore )
      console.WarningLn( "** Warning: The output format does not support the required sample data format." );
It does not do what I believed it does, it never warns, not even when 64-bit images are stored as 16-bit.

As a nice feature, maybe PixInsight might give a warning when user tries to "File->Save as" FITS format with lower precision. It already does warn about data loss when saving as jpeg.