Hi Steve,
Bernd is absolutely correct when he describes how each individual channel in the CFA (Bayered) OSC image is directly affected by the corresponding channel in the CFA Flat Frame.
I go so fed up having to then tackle the extra Colour Correction caused by the resultant colour cast that I started to look at the issue from a different perspective. First, we have to remember that Flat Field Correction relies on'division' of the Light by the Flat, and so we need to get the divisor to be as close to maximum as possible. However, we cannot over-expose the Flat frame, otherwise we get a saturate, and therefore non-linear image - which is not what we want.
So, we avoid saturating the image, but that leaves us with a non-maximal divisor. But the non-maximal divisor is a penalty that we have to pay, and which doesn't really affect us because PixInsight is quite capable of retaining numeric accuracy after the division because it natively works with 'real numbers' (Float variables - at up to 64-bit resolution, if you so wish).
And, if our imager had been a monochrome device, our work here would be done!
But, we effectively have a separate imager for each of the colour channels, where we can think of the 'gain' of each of the channels being directly related to both the colour of the incoming light and the sensitivity of a given channel to that colour of light. Even 'perfect white' light is likely to have a different effect on the pixels of each CFA to a different extent.
My first approach to the problem was to split the Master Flat Frame image into images representing each of the individual CFA filters. Using PixelMath, I then subtracted the maximum ADU value of each of the images from 1.0, and then added the result back to all the pixel ADU values for that image. This gave me an 'additively maximised' result for each channel. I then recombined these new images to give me a Master Flat Maximised image for use in subsequent calibration stages.
This worked, with some success, but still left a colour cast that needed to be eliminated during Post Processing - something that became easier to accomplish as PixInsight improved over the years.
This made me realise that the source of the problem was actually the 'colour' of the light used to expose the Flats - often too blue when using sky-flats, or too red when using artificial light. I needed a 'variable-colour' light source, and decided to try the now more readily available RGB leds, where each LED colour, and intensity, could be set, and memorised, by a master controller - on an LED by LED basis, if required.
I could finally now visualise the Histogram peaks more or less in real-time, and could tweak the LED controls to get the channels to line up, and to also give me a non-saturated ADU reading for my chosen exposure time.
Of course, all of this may be un-necessary detail for some, but it was a challenge that I enjoed tackling. Hopefully my ideas may inspire someone.