Hi again,
If the Create RAW Debayer Image is selected the output is RGB. Hence the need to convert to gray scale before debayering.
Exactly. I'll show you how this task can be accomplished easily in PixInsight. First I'll explain how to perform the conversion/debayering process manually. Then I'll show an automatic solution.
We start with a
RGB Bayer image. This is actually a raw CFA image, but each color filter element has been stored as a separate plane, instead of a single monochrome plane. In a RGB Bayer image each raw pixel is stored as a 2x2x3
cube: one red sample, two green samples and one blue sample stored in three separate rows. The nonexistent elements (8 in total) are set to black. This is how a RGB Bayer image looks like:
Loading DSLR CFA images as RGB Bayer images has some advantages for image calibration: our ImageCalibration tool is able to detect the Bayer pattern automatically in a RGB image, and it can compute dark scaling factors more accurately on a per-channel basis. The disadvantage is that the calibrated image files occupy three times more space on disk. To calibrate DSLR raw images as RGB Bayer images in PixInsight, you must set the following preferences for the DSLR_RAW format:
Note that you can also select the
Create RAW Bayer CFA image option, in which case the RGB-to-CFA conversion that I'm about to describe isn't necessary because you work with CFAs directly.
Before continuing, you've been told that you can use another application(s) to calibrate and stack your images in a more automatic fashion. That's true, and there are good applications out there. However, the recommended applications, even doing a nice work, can't rival PixInsight's ImageCalibration tool for automatic dark scaling (with total independence of temperatures and exposure times), StarAlignment for accurate image registration, and the sophisticated stacking and pixel rejection algorithms implemented in our ImageIntegration tool. This is just my opinion, and it is obvious that I am biased. Now let's continue.
So we have calibrated a set of images, and they have been written as RGB Bayer FITS image files by the ImageCalibration tool. The next step is debayering them, so we can align them with the StarAlignment tool. The problem is that the Debayer tool requires a monochrome CFA image to work; it doesn't accept RGB Bayer images. So we need to regenerate the original CFA prior to debayering. This task is very easy to do with PixelMath, as the following screenshot demonstrates.
The PixelMath expression computes the maximum of the R, G and B channels:
max( $T[0], $T[1], $T[2] )
Important: note the disabled
Rescale result option on PixelMath.
The above PixelMath instance replaces the original RGB image. This is not what we want, because Debayer requires a grayscale image. So we must tell PixelMath to send its result to a new grayscale image:
and finally we can apply the Debayer tool:
Obviously, doing this work manually is a tedious task if we have many images. One would think that ImageContainer and ProcessContainer can be used to implement this as a batch process. However, this is not possible in this case because the PixelMath result generates a new image, which is not supported (for now, this will change in a future version) by ImageContainer.
So the solution is a script. I have modified Ken Pendlebury's BatchDebayer script to implement this conversion. The whole task is carried out automatically; the script detects a RGB Bayer image and performs the required steps in a completely transparent way, so you only have to select your calibrated images, select an output directory, and click OK. I'm going to post the modified script on the New Scripts and Modules board in a few minutes.
Hope this provides useful information to all DSLR users.