After reading Bracken's Deep Sky Imaging Primer, I set out to improve my DSO image quality with calibration frames. His breakdown of the types of noise (Chapter 2 in particular) and the application of calibration frames (Chapter 14) is exceptional, but he gives practically no guidance on how to apply them. (Indeed, my favorite quote is "Fortunately, all of this heavy mathematical lifting is done for us behind the scenes by the calibration software." [emphasis mine]). The astroimaging world is reliant on this mythical calibration software, and in the wild, DSS and PI seem to be the automagical go-to for DSOs (and there seems to be very little appetite for Photoshop in particular). Yet when there's a problem, even the most expert of experts is stumped by something that should be solvable—even for something as simple as applying a flat. So I compiled this quick primer on Photoshop-only lights calibration.
I use Photoshop CS5 for MacOS X; there may be slight variations across versions and platforms, but the functions needed are about as basic as they get: layers, layer modes, layer opacity, and histogram adjustment (all present since version 3.0). The same functions exist in Gimp, but I've yet to dive into Gimp scripting.
I. Calibration Frames
I use all three calibration frame types referenced by Bracken: Master Bias, Master Darks, and Master Flats. I use Flat Darks (vice the Master Bias) to create the Master Flats; while there's minimal difference between the two, there are slight hot pixel increases in the Flat Darks that are amplified with a histogram stretch. I use Photoshop to create the stacks. I like stacks of 100 for each—the noise statistics seem to settle well enough for my purposes. I first use Adobe Camera Raw in Photoshop to adjust the Color Temperature and Tint of all the files to what I plan to use every time (and—most importantly—set the Blacks to 0). This is done as a batch by first selecting all the images in the preview pane (⌘-A) and then changing the values. Daylight defaults are probably fine; I use the numbers I derived from a gray card at high noon (e.g., Temp = 5000, Tint = -17 for ISO400). The stacking procedure is then
- File ⇒ Scripts ⇒ Load Files into Stack… ⇒ select 100 calibration images
- Starting from the bottom, set the layer opacity to 1/N, where N is the layer sequence number
- Layer ⇒ Flatten Image
For the second step, I like merging 10 at a time (i.e., set the opacity for 10 layers, select the layers, then Layer ⇒ Merge Layers) in the stack because the opacity sequence is easy to memorize (and I made a Photoshop Action to adjust and merge 10 layers from the current layer). The opacity sequence (from the bottom of the 10 to be merged) is 100%, 50%, 33%, 25%, 20%, 17%, 14%, 13%, 11%, 10%. Once I've created 10 sets of 10, I merge those 10 (i.e., set the opacity for 10 layers, select the layers, then Layer ⇒ Merge Layers), flatten, and save as a PSD. The merged stack of bias images is the Master Bias. The Master Dark is the dark stack with the Master Bias applied as a subtraction layer (i.e., Edit ⇒ Paste, and then select "Subtract" instead of "Normal" as the layer combine method in the drop-down menu in the Layer pane) and flattened.
The Master Flat is a bit trickier. I first apply the Flat Darks stack as a subtraction layer on the flat stack and flatten. I then use Levels to stretch the histogram by changing the white input clip level for each channel to the point where the histogram tapers off:
Figure 1. Flat histogram adjustment.
Putting it all together, here's my all-Photoshop workflow for calibration frame creation for a given ISO, exposure time, and aperture:
Figure 2. Photoshop-only calibration frame production.
a. Bias Frames
Bias frames are the easiest to remove. They're just applied as a subtraction frame with no scaling whatsoever. Bias is the largest source of sensor noise on my T3i, and thankfully it's temperature independent.
b. Dark Frames
Dark frames were the hardest to dissect. To first order, they're mainly hot pixels, but there's also some background noise with low spatial frequency to its structure. They're temperature dependent, and no two are the same—the sensor temperature changes the moment I use it, and I have no evidence that steady state is ever achieved (and plenty of evidence to the contrary). Hence why I apply bias frames separately vice simply including the bias with the dark.
Before applying the Master Dark to the light, I have to find the right level to apply. I do this by selecting a light from the middle of the imaging window and subtracting the Master Bias (as a subtraction layer). I then apply the Master Dark to it as a subtraction layer and then scroll through the Master Dark layer's opacity until I find the opacity at which the hot pixels in the image just start to disappear. I also hunt for hot red pixels—they turn blue when the dark is overapplied. That's the level I then use for the full imaging window. The opacity value is typically between 30% and 50%.
c. Flat Frames
The only hard part with flats is the creation of the Master Flat. Once created, it's simply applied as a divide layer.
Putting it all together, here's my all-Photoshop workflow for calibration frame application for a given ISO, exposure time, and aperture:
Figure 3. Photshop-only calibration workflow.
Manual production is exceedingly slow. But I successfully recorded Photoshop Actions for both calibration frame creation and lights calibration.
a. Changing and Selecting Layers for Stacking:
There's not a scriptable way to tell Photoshop to select a specific layer, so I use the Select Forward Layer (Option-] ) and Select Backward Layer keyboard commands (Option-[ ) to switch layers while recording actions. I can also multiple-select sequential layers with Shift-Option-[ or Shift-Option-]. For 10 layers in the stack, I make sure they're all visible and then make the bottom layer active. I then record the action from there with the keyboard commands for switching layers.
b. Changing Windows and Applying Calibration Images:
I initially created actions per calibration file, where the action opens the calibration file, copies it, closes it, pastes it to the image, changes the layer mode (subtract or divide), and flattens the image. But constantly opening and closing files that could remain open wastes a lot of time. So instead, the minimalist method I came up with to record an action was opening the Master Bias, Master Dark, and Master Flat files (in that order) and doing Select ⇒ Select All for each. I then opened a single sub on which to record the action. Photoshop treats windows as a stack, and when I select between windows while recording actions, Photoshop uses the current window as a reference ("Select Document ±n"). If I set the window sequence before recording, I can subsequently apply specific calibration files to a light if I open them the same way before running the action.
This leaves the problem of the adjusted Master Dark. This is solved easily enough—once I figure out the opacity, I use the Levels command on the open Master Flat to adjust the output whites level to the opacity level*255.
So the automation action (from the Light window, with the Master Bias, Master Dark, and Master Flat all open with Select All applied) is then
- Select Master Bias Window ⇒ Copy ⇒ Select Light Window ⇒ Paste ⇒ Set layer mode to Subtract
- Select Master Dark Window ⇒ Copy ⇒ Select Light Window ⇒ Paste ⇒ Set layer mode to Subtract
- Select Master Flat Window ⇒ Copy ⇒ Select Light Window ⇒ Paste ⇒ Set layer mode to Divide
- Flatten Image
This is then batch applied to the prepped (i.e., correct Temp, Tint, Blacks) light RAWs with the File ⇒ Scripts ⇒ Image Processor, with an output of TIFF with LZW compression. The TIFF output files are then ready for my favorite stacker.
Hope that's useful.