John,
As I see things (yet will be happy to be corrected) you have two (basic) choices:-
1.) You DeBayer first, then you Register and Integrate
2.) You Register and Integrate first, then you DeBayer
In (1) the resultant 'noise' that is generated by the DeBayer process is acquired many, many time - as many times as you have raw images.
In (2) the DeBayer 'noise' only gets generated once - when you process the final image and so, hopefully, is far less than in (1).
However, the very act of DeBayering requires that the colour information is extracted from within a 'group' of pixels - and it is the actual location of a pixel within a raw image that determines how the colour information should be extracted. This is why, I believe, that the preferred method is (1).
If you use (2), then each 'raw' pixel in the aligned image will effectively have 'lost' its original position within the coulour matrix - and so cannot be Debayered. However, given that the 'Reference' image used for the alignment process *does* still have its DeBayer reference, then it could be assumed that any image subsequently aligned with that reference still has a 'reference' for DeBayering (one caveat being that the Registered image must retain exactly the same pixel dimensions as the Reference image). In other wordseach Registered image must be 'cropped' (or 'padded', where necessary) to remain the same size as the Reference.
Of course, this has not considered processes involving Dark or Flat frames. With Darks, we don't need to worry about anything, as these are applied as Raw data to your RawLights - DeBayering has no involvement here.
However, this is not the case for Flats. To me, it seems (this time) that there are three choices:-
3.) You perform the FlatFrame division to each and every Raw image (before step (1) above)
4.) You perform the FlatFrame division to the final image (after step (2) above)
5.) You perform the FlatFrame division to each and every DeBayered image (during step (1) above)
In step (3), there will be cumulative 'noise' effects from each of the (many) division processes that will be implemented. However, there will be no noise contribution due to the DeBayering of the FlatFrame (which remains as a Raw image).
In step (4) the 'noise' from the division process is not cumulative, as the operation is only performed once.
In step (5), not only is there cumulative noise from the many division operations, but there is also the cumulative noise from the many DeBayer operations as well.
Of course - you have to also consider the Flats themselves. There are choices here as well (after all, a Flat is really just a Light!). Choices (1) and (2) apply - with the exception of the Registration process (as this is not required for Flats). In other words:-
6.) DeBayer each Flat first, then Integrate the resultant images
7.) Integrate all of the Flats, then DeBayer the final image
Again, in (6) there is cumulative 'noise' from the multiple DeBayer processes - whereas, in (7), there is only noise from one single DeBayer step.
Further, depending on the 'colour' of the light used to illuminate the CCD sensor during FlatFrame acquisition, you may well end up with a significant 'colour cast' after the division process - which will need to be eliminated later, during post-processing. So, do you try and 'fix' the colour cast before the division process, or do you treat it after the process?
I worked on a method that extracted each of the four DeBayer arrays from the MasterFlat (Integrated, but still in Raw format). Each of these was then 'normalised' (to result in the maximum value of any pixel being 1.0), before then recombining the four processed sub-images back into a NormalisedMasterFlat. This definitely resulted in a colour cast that was less noticeable, and easier to eliminate during post-processing (I don't use 'natural', or 6500K colour-temperature illumination for my flats, so I had noticeable colour cast that needed to be dealt with).
Note that a simple 'normalisation' of the image - without first splitting into the four CFA sub-images - does *not* help. In fact it makes things far worse, stretching the range of colour cast even further.
However, all of these thoughts are mine, and have not been discussed with others until now. I may be wrong (I often am
![laugh :laugh:](http://pixinsight.com/forum/Smileys/default/laugh.gif)
) - and I am happy to have others rip my arguments to pieces (providing they can justify why their solution has more merit
![tongueout :P](http://pixinsight.com/forum/Smileys/default/tongueout.gif)
).
In any case - I hope it helps you to start formulating your own thoughts.