Author Topic: DSLR Raw Format settings  (Read 5370 times)

Offline Walcho

  • Newcomer
  • Posts: 32
    • AstroWalcho
DSLR Raw Format settings
« on: 2017 February 09 00:03:27 »
Hello All,

In the DSLR Raw Format settings, I would like to understand the difference between the two options: Create Raw Bayer & Create Raw CFA.
In the previous versions of Pixinsight, I followed the general instructions found in internet which recommended to check the box: Create Raw Bayer. (What I did like a dummy, without asking me any question)  :)
With the last version of Pixinsight, we have the "Pure Raw" button which automatically check the box: Create Raw CFA (also recommended in internet). That’s what I do, but now I’m wondering why? (But don't draw too quickly the conclusion that in the meantime I became more intelligent!)  :D

My understanding is the following:
- The Raw Bayer: The pictures in raw format will be displayed in color (RGB) in Pixinsight. Raw taken after the Bayer matrix?
- The Raw CFA: The pictures in raw format will be displayed in gray level in Pixinsight. Raw taken before the Bayer matrix?

My two questions:
- Is my understanding correct?
- What will be difference if I check the one or the other option at the end of the pre-processing? Especially after debayering?

Thank you.

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: DSLR Raw Format settings
« Reply #1 on: 2017 February 09 06:54:47 »
The global settings in Format Explorer/DSLR_RAW (respectively: the input hints in certain Pixinsight processes - they will overrule the global settings!), determine how the raw photo (e. g. a *.CR2 file)

- is tranformed by the Raw Photo Decoder (Pixinsight uses 'dcraw' for decoding the raw photos),
- is represented on the screen, in memory or on disk if you save the data to a file subsequently.

When opening a raw photo (e. g. a *.CR2 file) the settings in DSLR_RAW (respectively: the input hints) are passed on to dcraw in a suitable form. dcraw decodes the photo and supplies the data: a header that contains some metadata and a matrix (dimensions: width x height) with grayscale intensities of the sensor's pixels. dcraw has numerous possibilities to alter the data (scaling, white balance, etc.). So it must be advised to keep its hands off, if we want to do a correct preprocessing. You must be aware that this matrix is yet monochrome data that contains the structure of the Bayer matrix (e. g. RGGB). Therefore it is not an image in the conventional meaning.

How Pixinsight represents this matrix is also determined by the settings in DSLR_RAW (respectively: by the input hints). When choosing "Create raw Bayer CFA image" the representation is as grayscale "image", when choosing "Create raw Bayer RGB image" the representation is as RGB "image" (I set Image in quotation marks because of the still inherent Bayer matrix.). The RGB "image" represents the same contents and roughly occupies threefold the disk space of the CFA "image". So I recommend to set "Create raw Bayer CFA image".

The preprocessing is done with data in that format (inherent Bayer matrix). After preprocessing but before registering and integrating we have to get rid of the Bayer matrix. The process of "debayering" converts the grayscale "image" to a real RGB image.

There is one point that has been subject of a discussion some time ago ("DSLR_Raw Settings: CFA or not", topic 2362.0). Juan Conejero then stated:

Monochrome CFA images will work nicely and you're right with just one exception: dark frame optimization. Dark scaling will be more accurate with RGB Bayer images because an independent scaling factor will be computed for each channel. With a monochrome CFA, only one scaling factor will be computed as an "average" for the three channels, which also will work, but less accurately. Whether there are practical differences in the final calibrated images depends on the images TM :)

Note that this is actually a limitation of our dark optimization routine, due to the fact that it has been designed to work with each channel as an independent image (which is what they are for calibration purposes). I'll try to implement a special routine to compute independent RGB scaling factors from monochrome CFA images as soon as possible. When that happens, then there will be no reason to calibrate with RGB Bayer images anymore.

I don't know whether the dark frame optimization routine was adjusted since that time. Maybe anybody else can clarify this yet?

Bernd


Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: DSLR Raw Format settings
« Reply #2 on: 2017 February 09 08:25:05 »
I don't get why you'd want to do the dark frame scaling in a per channel basis. Dark current has nothing to do with the bayer matrix filters. It is generated by heat from the sensor. I would not expect a significant change in the weights between each color.
Regards,

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

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: DSLR Raw Format settings
« Reply #3 on: 2017 February 09 11:50:13 »
I don't get why you'd want to do the dark frame scaling in a per channel basis. Dark current has nothing to do with the bayer matrix filters. It is generated by heat from the sensor. I would not expect a significant change in the weights between each color.

I quoted a post of Juan Conejero, the developer of Pixinsight. That was not my idea. (In fact I have joined this forum in novermber 2016 and am a novice here.

If the statement is wrong, it should be corrected. That was what I intended with my question.

Bernd

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: DSLR Raw Format settings
« Reply #4 on: 2017 February 09 14:42:46 »
Quote
I don't get why you'd want to do the dark frame scaling in a per channel basis.

The CF generates a strong pattern at the one pixel scale that prevents noise evaluation on CFA frames, both monochrome and color. To overcome this we apply a software binning 2:1 to CFA frames prior to noise evaluation. When the CFA frame has been loaded as a monochrome image, the binning process averages all 4 pixels in each 2x2 region. This acts like a low-pass filter that degrades the noise evaluation result. When the CFA has been loaded as a RGB image, the binning process effectively isolates individual CFA components as compact two dimensional matrices, which provides more accurate noise estimates. As I said in the original post back in 2010, this difference obeys to a technical limitation of the noise evaluation routines implemented in the ImageCalibration tool. In other words, the routines should perform a separation of CFA components automatically and transparently.

On the other hand, the goal of dark frame optimization is to minimize the noise in the RGB image, not in the CFA frame. The fact that a CFA raw frame is stored as a monochrome image is irrelevant here because the underlying data object is a RGB color image. Since the spatial distributions of RGB components over the CFA are different (and, in the case of a Bayer CFA there are twice more green pixels than red and blue), and the spectral responses of CFA filter components are also different, evaluating the noise separately for each component is the correct procedure and, in the case of dark frame optimization, tends to yield more accurate scaling factors. Also as I said in the original post, whether this has a visible repercussion on the final calibrated/interpolated image depends on a variety of factors. The BatchPreprocessing script forces the use of monochrome CFA frames with the "raw cfa" hints for practical reasons, with usually excellent results.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Walcho

  • Newcomer
  • Posts: 32
    • AstroWalcho
Re: DSLR Raw Format settings
« Reply #5 on: 2017 February 10 02:13:52 »
Thank you very much for those answers.
It's much more technical than I imagined (my neurons have heated).

Here is a short summary to check if I understood correctly:

In absolute terms, the Raw Bayer (RGB) is more efficient in noise estimation, so in theory in the DSLRRaw Format panel, we should check the Raw Bayer (RGB) box. But the scripts use CFA frames for practical reasons and that's why we check the Raw CFA box in the DSLRRaw Format panel.
Since the processing of the image depends on many factors, in both cases very good results can be obtained.

Did I understand correctly ?

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: DSLR Raw Format settings
« Reply #6 on: 2017 February 10 05:07:15 »
Yes. With RGB CFA frames we need three times the storage space required for monochrome frames. Te potential benefits of a more accurate dark frame optimization, given the intrinsic problems of DSLR data, normally don't justify that waste. That's why the BPP script works with monochrome CFA frames via format hints.

A future version of the ImageCalibration tool will replace the current dark frame optimization algorithm with an improved version, which have already designed. Among other more important improvements, the noise evaluation routines will split CFA components automatically to compute separate scaling factors.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline llpastro

  • PixInsight Addict
  • ***
  • Posts: 199
    • Sonoran Dark Skies
Re: DSLR Raw Format settings
« Reply #7 on: 2017 February 10 06:23:40 »
Juan, is your comment about a new noise algorithm also true for monochrome images or just Bayer?

Larry
AP 140 Refractor
SBIG ST-10XME
AP Mach 1 Mount
ATS Portable Pier
Tucson, Arizona

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: DSLR Raw Format settings
« Reply #8 on: 2017 February 10 09:36:46 »
Ok, I get it. :) The problem comes from the light image. Anyhow, I would expect that the calculated weights should be the same since the dark current do not have a color dependency.
Regards,

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

Offline bulrichl

  • PixInsight Guru
  • ****
  • Posts: 524
Re: DSLR Raw Format settings
« Reply #9 on: 2017 February 24 07:47:22 »
I wanted to clarify whether it really makes a difference in practice when dark frame optimization is done with the DSLR_RAW setting "Create raw Bayer RGB image" instead of "Create raw Bayer CFA image", so I tested it. The outcome is: for my camera (Canon 600D) it doesn't. Here are the k's for the calibration with optimization of 31 light frames (ISO 800, 360 s, 14 °C) with a MasterDark from 40 dark frames (ISO 800, 360 s, 16 °C) and a MasterBias from 40 bias frames(ISO 800, 1/4000 s, 20 °C):

     Bayer CFA      Bayer RGB
     k0         k0      k1      k2
06   0.519      0.501   0.510   0.489
07   0.658      0.653   0.653   0.643
12   0.499      0.490   0.488   0.473
13   0.617      0.610   0.605   0.602
14   0.661      0.677   0.671   0.659
15   0.713      0.708   0.707   0.710
16   0.727      0.728   0.722   0.722
17   0.749      0.749   0.710   0.740
18   0.756      0.758   0.751   0.758
19   0.759      0.777   0.740   0.766
20   0.769      0.775   0.765   0.767
21   0.771      0.768   0.766   0.773
22   0.773      0.780   0.770   0.773
23   0.771      0.775   0.763   0.767
24   0.751      0.755   0.749   0.739
25   0.753      0.758   0.746   0.758
26   0.739      0.752   0.738   0.744
27   0.743      0.744   0.739   0.737
28   0.735      0.738   0.737   0.725
29   0.728      0.728   0.728   0.724
30   0.719      0.726   0.721   0.720
31   0.726      0.722   0.714   0.712
32   0.703      0.702   0.697   0.702
33   0.702      0.699   0.694   0.687
34   0.686      0.696   0.697   0.686
35   0.687      0.691   0.692   0.679
36   0.680      0.687   0.687   0.676
37   0.675      0.675   0.668   0.666
38   0.673      0.681   0.675   0.667
39   0.680      0.692   0.692   0.691
40   0.699      0.697   0.695   0.699

There is virtual no difference between the k's of one frame, neither between Bayer CFA / Bayer RGB nor between the k's of the 3 channels with Bayer RGB. After that it is not surprising that there is no difference in the noise estimates of the integrations (after debayering and aligning) either:

For both settings:
Pixel combination ......... average
Output normalization ...... additive + scaling
Weighting mode ............ noise evaluation
Scale estimator ........... iterative k-sigma / BWMV
Range rejection ........... range_low=0.000000
Pixel rejection ........... none

Bayer CFA:
Gaussian noise estimates  : 9.9513e-005 9.7286e-005 9.4333e-005
Scale estimates           : 2.6645e-004 2.8470e-004 1.7082e-004
Location estimates        : 6.4226e-003 6.4941e-003 2.5495e-003
SNR estimates             : 5.7936e+003 6.5310e+003 2.1265e+003
Reference noise reduction : 2.0085 2.2739 1.4614
Median noise reduction    : 2.2374 2.4947 1.6788

Bayer RGB:
Gaussian noise estimates  : 9.8232e-005 9.6703e-005 8.6928e-005
Scale estimates           : 2.6310e-004 2.8269e-004 1.4191e-004
Location estimates        : 6.4261e-003 6.4958e-003 2.5556e-003
SNR estimates             : 5.9072e+003 6.5825e+003 2.2721e+003
Reference noise reduction : 2.0089 2.2708 1.4375
Median noise reduction    : 2.2355 2.4957 1.5135


So my sum is, that I will keep the setting "Bayer CFA" in DSLR_RAW and continue to save a lot of hard disk space.

Bernd