Hi there,
I come across this problem all the time (if I have correctly understood your description
***), and I associate it with the use of Flats in the CFA calibration process.
*** EDIT: Obviously, I didn't really understand your issues clearly, however I will leave this post in situ as I still believe it has some meritThe problem is less obvious when dealing with a Mono imager and line-filters (WB or NB) because each 'channel' is calibrated separate from the other channels. However, this is unfrtunately not the case for a CFA imager.
This time, the normal process is to calibrate 'raw' (or CFA-bayered) Lights with similar 'raw' flats - but in a single stage of image 'division' (rescaling back to the normal 0.0 -> 1.0 rabge used internally by PI as required).
However, in the four CFA 'channels' (typically one Red, two Green and one Blue - or one each of Cyan, Magenta, Yellow and Green if you are using a CMYG imager) each channel has its own 'peak' - these can be clearly seen if you look at your MasterFlat on the Histo window. And, when the 'division' process takes place (during the Flat Calibration procedure) the highest peak (closest in value to 1.0) will have less effect on the calibration output image than the peak with the lowest average value which, being the denominator of the division process will cause a significantly higher result than a higher-value denominator would.
In plain terms, those peaks on the left of the Histogram will cause equivalent colour casts after Flat Calibration (once the image is debayered).
EDIT The reason for all of the peaks not being aligned is a comnination of a light source that, perhaps, is not perfectly 'white', and the attenuation of the CFA filters not having been equalised by the manufacturer. What you are performing is a sort of 'white (im-)balance compensation' for your MasterFlatSo, how to solve things?
Fortunately PixInsight coninues to improve, and tools get better. However, there is still not a simple 'one-click' process or script that will solve things - but there are two (new-ish) tools that now make life far easier (at least for me, anyway). These are the SplitCFA (script) and MergeCFA (process). And they are pretty self-explanatory, and relatively simple to use (but are not compatible with CMYG arrays). One splits out all pixels in a RAW image, such that four new images are created, one each for the four coloured filters in the Bayer array. And the second simply recombines each of these four (Grey, or Mono) images back into a RAW image again (ready for subsequent Debayering).
Obviously, we still need to do something 'clever' in between using these two tools. And that will be a simple PixelMath operation. And don't worry, it really is simple! Here goes . . .
In the Expressions pane, the only thing that you need is the following formula entered into the RGB/K field:
$T+(1-max($T))
You should have nothing else in this pane, but you should ensure that you tick the [Use single RGB/K expression] option.
In the Destination pane, you should (only) tick the [Generate Output] selection, and you should only select the [Replace Target Image] option.
Then just drag and drop the instance on to each of the four extracted images obtained when you used the SplitCFA script. Once you have done that, you simply use the MergeCFA process to generate a new NormalisedMasterFlat.
You use this image instead of your 'standard' MasterFlat for all subsequent calibration operations, and (hopefully) your colour-cast issues will be significantly reduced.
So, how does it work? Well, remember the expression that you entered:
$T + ( 1 - max($T) )
What this does is to first extract the maximum value of the 'Target' image (the image you will drop the process instance arrow-head on, referred to as $T in the expression).
Then it works out how much less this value is compared to '1.0' (the maximum value of a pixel in PixInsight).
With this 'free head-room' now known, each and every pixel value in the $T image can be increased by this amount.
The very brightest pixel(s) in the image will now be 1.0 - and in the subsequent division process of flats-calibration, pixels at these locations will now not change in value (because dividing by '1' doesn't change the numerator - the result stays the same).
And, similarly, because the faintest pixels values (at the worst points of vignetting or dust-donutting) are being divided by relatively 'higher' values, their subsequent changes are noticeably less (still enough to help eliminate the shading, but not now quite so 'harsh' - IMHO)
And, because each colour channel has had a totally separate scaling function applied, you no longer have possible huge disparities between the Histo peaks anymore - look at the Histo of the recombined NormalisedMasterFlat to see the evidence of this.
All in all - this works for me. I don't do any calibration without performing this small little step. It doesn't take long to do, and it makes subsequent BackgroundNeutralisation and ColourCalibration far easier. It also seems to have the effect of keeping noise levels down prior to the start of post-processing.
Anyhow - give it a try. Your mileage may vary, but I hope it helps (and, as always, I welcome criticism from those far more knowledgeable than I
)