This is my first script, and my very first attempt at using Java Script. Feel free to improve the script or provide advice. I have tested it with my own SLR camera.
The script should produce excellent color balance for an SLR camera provided that no filter is used and the camera has not been modified. In either of these two cases, see the next post by Mike (msmythers) and my reply.
SLR cameras are calibrated for accurate color balance. It is therefore possible to create an integrated stack with perfect color balance. The only color correction required will be to subtract any light pollution background (e.g. use DBE or BackgroundNeutalization).
To achieve this, this script modifies the RGGB pixels in a master CFA Bayer flat so that:
(1) Any color cast is removed from the flat
(2) The user supplied color balance is applied to the RGGB pixels
The script requires a master flat (.fit or .xisf). It must not be DeBayered. When creating the master flat, make sure to set the raw format to pure bayer:
Format Explorer -> DSLR_Raw <double click> Pure Raw
I use the ImageCalibration tool rather than the BatchPreprocessing script, so I have not tested this script with flats calibrated with BatchPreprocessing.
To determine the color balance values, take a photo with the white balance set to 'Daylight'. The contents of this image, and the lighting is not important. Load the raw image into PixInsight. In the Console, look for:
Camera multipliers: 2255.000000 1024.000000 1730.000000 1024.000000
These values are for the Canon 5Dmk2, and correspond to Top left (Red), Top right (Green), Bottom Right (Blue), Bottom Left (Green). However, provided you enter the correct scaling factor for the bayer positions (e.g. top left, top right, bottom right, bottom left) the actual bayer pattern should not matter. Note that a high value refers to a pixel color with lower sensitivity.
I have also attached an image processed with a sky flat that had been processed with this script. No extra color balance changes were required, only background light pollution subtraction. The image was taken with a 5Dmk2 + 100mm lens at F2.8, Astrotrac, 52 x 120 second exposures. I applied some noise reduction and a histogram stretch to the raw stack.
The script's initial aim was to remove the blue cast from sky flats (it can still do this - just set all the multipliers to 1). Now that it also compensates for the camera's white balance I should probably rename the script.
Hope it is useful
John Murphy