Table of Contents
IntroductionThere are many instances where calibration frames do not properly calibrate an image or where time or conditions do not afford the opportunity of taking them. In many cases the resulting vignetting and gradients can be removed with tools like DynamicBackgroundExtraction (DBE) or AutomaticBackgroundExtraction (ABE). However, there are some cases where the scale of the structures (meaning they are too small) cannot be corrected by these processes. For those situations, I find creating a synthetic flat does a better job of correcting the background. The process I use is fairly straightforward, however, depending on the image and the data you have access to, there can be a lot of manual clone stamp work involved. This process works best when any nebulosity or faint structures represent a small portion of the image. As our example, I will use Anis' M101 data which exhibited banding issues that his flats did not correct.
Synthetic Flat Creation with Subframes and DitheringLet's look at the case where you have all the individual sub frames. Starting with an already stacked frame uses the same process but it is a bit more difficult to remove structures. Assuming there is some amount of drift in your images due dithering (or due to unintentional drift) we can utilize the rejection capabilities of ImageIntegration (II) to create something very close to a flat by stacking all the individual subs without registration. Figure 1 shows the settings I used with Anis' data to create this first pass synthetic flat (this was using non-calibrated subs but you can do the same with fully calibrated data too). Figure 1: ImageIntegration - Aggressive Rejection In general, the settings are similar to what I normal default to for light frame stacking, however I set the Sigma low and Sigma high very low so that more stars and nebulosity will be rejected. Figure 2 shows the resulting stack. You can see M101 and a few stars exist but are mostly removed. Hot pixels are still prominent because there was no dithering or calibration to remove them Figure 2: First Pass Synthetic Flat Let's get rid of those hot and cold pixels. Bring up PixelMath and put in the following symbols:
f=6.0, w, h, x0, x1, x2, y0, y1, y2, p00, p01, p02, p10, p11, p12, p20, p21, p22, value, sdAnd this expression:
w = width($T)-1; h = height($T)-1; x1 = x(); y1 = y(); x0 = iif(x1<1, 0, x1-1); y0 = iif(y1<1, 0, y1-1); x2 = iif(x1>w, w, x1+1); y2 = iif(y1>h, h, y1+1); p00 = pixel($T, x0, y0); p01 = pixel($T, x0, y1); p02 = pixel($T, x0, y2); p10 = pixel($T, x1, y0); p11 = pixel($T, x1, y1); p12 = pixel($T, x1, y2); p20 = pixel($T, x2, y0); p21 = pixel($T, x2, y1); p22 = pixel($T, x2, y2); value = med(p00, p01, p02, p10, p12, p20, p21, p22); sd = sqrt(bwmv(p00, p01, p02, p10, p12, p20, p21, p22)); iif(p11>(value+(f*sd)), value, iif(p11<(value-(f*sd)), value, p11))The resulting PixelMath window should look like Figure 3. Apply that to the flat. The resulting image should look like Figure 4. This can also be done with the CosmeticCorrection (CC) tool, but I've been using this method since before CC was introduced as a process and I feel I have more control over it this way. Figure 3: PixelMath - Removing Hot Pixels Figure 4: Hot Pixels Removed At this point you could start CloneStamp-ing this image to remove the residual star and galaxy data and depending on size of the structures you are trying to remove with the flat, that might be the correct course. For example, in Anis' image there is strong vertical banding on the left side of the chip (it's hidden in the above image due to the vignetting). The scale of those bands are on the order of 30 pixels so to make sure they are corrected by the synthetic flat I can't do anything to the image that destroys structure sizes over that. Let's bring up the MultiscaleMedianTransform (MMT) and see if we can improve the image before resorting to the CloneStamp tool. Figure 5: MultiscaleMedianTransform - Removing Small Scale Structure Figure 5 shows MMT with 5 layers, all 5 of which are disabled. This means that structure sizes from 1 pixel up through 16 will be removed, 32 and above will be retained. When you apply it to the image it will look like the image is blurred but it's not exactly the same process. I've tried this with MultiscaleLinearTransform as well, but I prefer the results from MMT. Figure 6 shows the resulting image. Figure 6: Result of MMT on Synthetic Flat It's a little hard to tell from this scaled down image (the original image is 3326 x 25040) but some of the fainter stars and a lot of the small scale noise has been removed. Next we need to clean up the remaining stars and M101 at the center. Bring up the CloneStamp tool. It is a dynamic process so click on the synthetic flat image window and it will be come the active window. I usually set the opacity very low so that I can accumulate changes. When you are ready to start CTRL click in the image where you want to copy data from and then click on the target you want to replace. Figure 7 shows this process right before I attempt to remove the remnants of the small galaxy to the lower right of M101. Figure 7: CloneStamp - Removal of Remaining Structures This is the toughest part of the process. You have to find locations of equal noise and intensity to use as a source for the clone stamp. Vary the size, softness and opacity as you need to remove all the remaining structures. The end result should look something like Figure 8. Figure 8: Final Flat You can see that I had to guess at intensity levels where M101 was at. It probably took 50 clone stamp steps to remove all the stars and then another 60 to remove M101. Once you get the hang of it, it goes pretty quickly. Now that we have a synthetic flat, we need to use it to calibrate our images. I started with uncalibrated data so this synthetic flat needs to be applied to the uncalibrated subs. If you have darks, bias or flats, you should run 2 calibration steps. First calibrate with the normal calibration frames then run through this process using the calibrated subs to create the synthetic flat then calibrate the calibrated subs with the new flat (darks and bias disabled). Figure 9 shows how I typically run ImageCalibration with the synthetic flat. Figure 9: ImageCalibration - Using Synthetic Flat We should now have a set of well corrected sub frames that we can stack. Go through your normal process to register and integrate these. You can use my PixInsight Manual Image Calibration, Registration and Integration tutorial if you need more details on those processes. Figures 10 through 13 show a comparison of the synthetic flat vs no correction, ABE & ABE+DBE. Figure 10: No Correction Figure 11: ABE only Figure 12: ABE + DBE Figure 13: Synthetic Flat Correction While the synthetic flat is not perfect it can do a much better job than ABE or DBE in many situations.