← Guides

Continuum subtraction: no more red background where there is no Hα

Christian van den Berge20 min read

You add Hα to your colour image to bring out the nebulae, and the background turns red too. Not just around the nebulae: everywhere, also in places where there is no Hα at all. It’s a very common problem, and turning down the Hα doesn’t solve it. It only makes the nebulae weaker along with it.

The cause is that a narrowband filter doesn’t only let through the light of a nebula. It lets through everything in a narrow slice of the spectrum. The background of your image, the glow of a galaxy or the Milky Way, the dust, shines in that slice as well. That broadband light is called the continuum. So an Hα image is always Hα plus a faint copy of the ordinary broadband picture, and when you add it to red, you add that copy too.

Often you can ignore that. But when I went back to my 2016 and 2017 data this autumn, it turned out to matter in almost every image where I mixed narrowband into colour. In one of them, more than half of the light in my starless OIII stack wasn’t OIII at all. In this guide I show how I measured the continuum and took it out, with the results on the actual data.

The problem: red where there is no Hα

Here is the problem on real data. The same Hα, at the same strength, added to the red channel of the Small Magellanic Cloud:

The Small Magellanic Cloud in three versions. RGB only: a neutral, slightly greenish glow. With Hα added: the nebulae are red, but the whole glow of the galaxy turns pink as well. With continuum-subtracted Hα: the nebulae are just as visible and the glow is neutral again

Left: RGB only. Middle: with Hα as it came out of the stack. Right: with the same Hα after continuum subtraction. Starless previews with one and the same stretch. The reddish tint that remains at the edges is a leftover background gradient.

In the middle the galaxy itself turns pink. Not its nebulae, but its glow: that’s ordinary broadband light that passed through the Hα filter. On the right, the red is where the hydrogen is, and the rest keeps the colour it had.

I measured it in a patch of the galaxy without nebulae. The ratio of red to green there is 0.88 in the RGB image, 1.33 with Hα added, and 0.90 with subtracted Hα.

This is the Hα itself, before and after:

Hα image of the Small Magellanic Cloud. Left: the starless stack, with the nebulae embedded in a broad bright haze. Right: after subtracting 0.0329 times the red channel, the haze is gone and the shells and nebulae remain

Hα before and after. Both panels use the same stretch; only the sky level is matched. The haze on the left is the broadband glow of the galaxy: the part that would have turned pink.

Key takeaways

  • The symptom is a coloured background: red where there is no Hα, teal where there is no OIII.
  • Narrowband = line + continuum. The continuum is all the broadband light in the field: the glow of the Milky Way or a galaxy, reflection nebulae, dust, the sky, and the stars. It gets through the filter in proportion to the filter’s width.
  • It’s not about the visible stars. Removing them with StarXTerminator leaves the continuum of the background in place.
  • Subtract a scaled broadband image: line=narrowband−k×broadband\text{line} = \text{narrowband} - k \times \text{broadband}, on linear, starless, registered data.
  • Use the stars to measure kk, even though it’s the background you want to fix. Ordinary stars are pure continuum, so their flux ratio between the two images is kk. Fitting the whole image gave me answers that were wrong by up to a factor of nine.
  • How much it matters depends on the target. In my Lobster data it was about 15 % of the Hα but 54 % of the OIII.
  • Subtraction is not a clean-up. It adds noise and leaves a small residue. Denoising and a threshold come after it.

What the continuum is

Hot gas shines in a few sharp lines, like Hα at 656.3 nm. Most other light is spread smoothly over all wavelengths: a continuum. A filter that is several nanometres wide catches the line, but also a strip of continuum.

Schematic spectrum around 656 nm: a smooth continuum with a sharp Hα line on top. The narrow Hα filter contains the line and the strip of continuum below it. The much wider red channel contains far more continuum and the same line

It’s easy to think of this as a star problem, because stars are the most obvious continuum sources. But the stars you can see are the easy part: you can remove them. What colours your image is the background, everything between the stars:

  • The glow of the Milky Way or of a galaxy: the combined light of countless stars too faint to resolve.
  • Reflection nebulae and dust, including cirrus, which scatter light from elsewhere.
  • The sky itself: airglow, moonlight and light pollution. The even part of it disappears when you set the background level, but a gradient doesn’t.

StarXTerminator takes out the points of light and leaves all of that. So a starless Hα image is not a continuum-free Hα image.

Dark clouds are a good giveaway. If you can see dust lanes in silhouette in your OIII image, in places where nothing emits OIII, then you’re looking at a broadband background with dust in front of it.

The basic formula

A broadband image of the same field tells you where the continuum is. Scale it to the strength it has in the narrowband image, and subtract:

line=NB−k×BB\text{line} = \text{NB} - k \times \text{BB}

I use the red channel for Hα and the blue channel for OIII. Green also works for OIII, but in my Lobster data blue predicted the star fluxes better: 9 % scatter against 15.5 %.

Four conditions have to hold for this to work:

  • Linear data. Light adds up only before the stretch.
  • The same pixel grid. Register the two images onto each other accurately.
  • No stars left in either image, or star images that match perfectly (more on that below).
  • A known sky level. Both images have their own background, so after the subtraction the zero point has to be set again.

Finding k from the stars

Everything depends on kk. You can’t measure it on the background, because you don’t know which part of that is line emission. That’s what the stars are for. They’re not what we want to remove, but they make a good reference. An ordinary star has no strong line emission, so whatever the narrowband image shows of it is continuum. Compare how bright the same star is in both images, and that ratio is kk. Do it for many stars and take the median. Below is how to do that in practice.

For this guide I measured the Lobster and Cat’s Paw again from scratch, on about 2,300 stars:

Two scatter plots of about 2300 stars. Left, Hα divided by red: the ratio falls clearly from red stars to blue stars around a median k of 0.0529. Right, OIII divided by blue: a flatter cloud around a median k of 0.0592

this re-measurement used in the image (8,342 stars) star-to-star scatter
Hα against R 0.0529 0.0515 18 %
OIII against B 0.0592 0.0587 9 %

Two different selections of stars agree within 3 %. The plot also shows the weakness of the method: kk depends on the colour of the star. For Hα, the reddest quarter of the stars gives 0.063 and the bluest quarter 0.046. A single number is a compromise for the average star colour. OIII sits in the middle of the blue channel, so it suffers less.

When the colour term gets large, use two channels. For RCW 106, I fitted Hα = 0.093 G − 0.075 B on the stars, which brought the scatter down from about 32 % with one channel to 11 %.

Measure kk on the same files you’ll subtract, or at least on files with the same scaling. Colour calibration multiplies the channels, and kk changes with it. In RCW 106 the stars’ Hα/R ratio was 0.040 on the raw colour stack and 0.023 after SPCC. Neither number is wrong, but they don’t mix. It also means you can’t copy my values: yours depend on your filter, camera, exposure and calibration.

How to measure k yourself

What you need is the flux of a star: the total light it adds on top of its background. Not the peak value, because the peak also depends on how sharp the star is, and that differs between your two images.

One star, step by step

Take the linear, registered images with their stars (in PixInsight, use the RGB file you’ll also subtract, and look at one channel). Then:

  1. Pick a star that is clearly visible in both, not saturated (peak well below 1, say under 0.6), and without close neighbours.
  2. Draw a small box around it, large enough to hold the whole star in both images. I used 15 × 15 pixels. Read the mean.
  3. Draw a larger box around the same star, 51 × 51 pixels. Read the median. That’s the local background, and the median ignores the stars in it.
  4. Subtract: mean of the small box − median of the large box. That’s proportional to the star’s flux.
  5. Do the same at exactly the same place in the other image.
  6. Divide narrowband by broadband. That’s kk for this star.

One star from the Lobster data in Hα and in red, each with a small box around the star and a larger box for the background. Hα: 0.002376 minus 0.002258 is 0.000118. Red: 0.005036 minus 0.002681 is 0.002356

A real star from the Lobster field: 0.000118 / 0.002356 = 0.050. The number of pixels in the box is the same for both images, so it cancels.

In PixInsight the boxes are previews, and the Statistics process shows the mean and median of each. Set it to show enough decimals (Normalized Real [0,1], scientific notation helps). Give the previews in the second image the same position and size, via Preview > Modify Preview.

How many stars?

More than you’d think, because stars have colours. I tested the method with boxes on 235 suitable stars in the Lobster field, by drawing random samples from them:

stars in the sample Hα: median k, spread OIII: median k, spread
1 ± 43 % ± 18 %
5 ± 13 % ± 5 %
10 ± 7 % ± 3 %
20 ± 5 % ± 2 %
40 ± 3 % ± 1 %

So one star tells you almost nothing, and 20 is a good number. With all 235, the boxes give 0.050 for Hα and 0.058 for OIII, against 0.053 and 0.059 from photometry on 2,300 stars. Spread your stars over the field, include red and blue ones, and skip the ones inside bright nebulae. Use the median, so one odd star (a double, a variable, an emission-line star) doesn’t pull the result.

A quick estimate from the star images

If you run StarXTerminator with the star image on and unscreen off, you have two images that contain only stars. The ratio of their means is then roughly kk, with no boxes at all:

k≈mean of the narrowband star imagemean of the broadband star imagek \approx \frac{\text{mean of the narrowband star image}}{\text{mean of the broadband star image}}
mean ratio of the star images k from individual stars
RCW 106, Hα / R 0.0231 0.0233
SMC, Hα / R 0.0289 0.030–0.033
SMC, OIII / B 0.0393 0.036–0.038

That’s within about 12 % for my data. Saturated stars and whatever faint glow ended up in the star image distort it, so use it as a starting value and check it with the dust clouds.

Let software do it

  • PhotometricContinuumSubtraction by Charles Hagen is a free PixInsight script that measures the stars in linear narrowband and broadband images, works out the weights and does the subtraction. It can also plot narrowband flux against broadband flux, which shows whether the fit makes sense.
  • AperturePhotometry (Script > Photometry) comes with PixInsight. It measures the stars of a catalogue in plate-solved images and writes their fluxes to CSV tables, with a flag for saturated and overlapping stars. Put the fluxes of the two images side by side in a spreadsheet, divide, and take the median.
  • My own PixInsight script, below.

I haven’t compared the first two with my own numbers. Whichever you use, check the result: the next section shows how.

My PixInsight script

For this guide I turned my Python measurements into a script for PixInsight 1.9.4 or newer:

Download ContinuumSubtraction.js (free, open source)

Save it, then run it with Script > Execute Script File. To keep it in the menu, put it in a folder OwlAstronomy and add that folder under Script > Feature Scripts; it then appears as Script > OwlAstronomy > ContinuumSubtraction. It isn’t code-signed, so PixInsight may warn you about that.

  1. Choose the narrowband and broadband images with stars, and the starless versions of the same two. Without starless images it works too, but the stars will leave residue.
  2. Choose the continuum channel: red for Hα and SII, blue for OIII.
  3. Measure k. The script finds isolated, unsaturated stars, sums each one in a circle of 6 pixels radius, subtracts the median of a ring around it, and takes the median of the ratios. It’s the same method as the boxes, on thousands of stars.
  4. Read the report: the scatter, kk for red and for blue stars, the share of continuum in the image, and the correlation check from the next section. The plot shows the ratio of every star against its colour. If the points form a clear slope, try Green and blue (two channels).
  5. Change kk if you want to, press Check to see what that does, and Create image. It sets the zero level, adds the pedestal, and tells you if any pixels were clipped.

On my Lobster data it gives 0.0520 for Hα and 0.0590 for OIII, from 8,513 stars, against 0.0515 and 0.0587 in the image I published. It makes mistakes as any script does, so look at the result.

What the right k looks like

This is the OIII of the Lobster field with four amounts of subtraction. They all have the same stretch.

Four versions of the Lobster OIII image. Not subtracted: dark dust clouds and Milky Way glow. Half of k: the dust is still faintly visible. Full k: the dust silhouettes are gone and the nebulae remain. Twice k: the dust turns bright and the nebulae get black holes

You can see when it’s right. With too little subtraction the dust clouds stay dark. With too much they turn bright, like a negative, and black holes open up in the nebulae. At the star value the dust disappears into the background.

It can also be put in a number: the correlation between what’s left and the broadband image, in the faint 70 % of the field.

amount of subtraction correlation with the blue channel
none 0.63
k × 0.5 0.40
k × 1 0.07
k × 1.5 −0.28
k × 2 −0.55

The stars played no part in this test, and still the correlation nearly vanishes at the value they gave. I use this as a check rather than as a way to find kk, because in many fields real gas follows the same dust.

Here is the same field, larger, before and after:

The Lobster and Cat's Paw field in OIII. Top: the starless stack, with Milky Way glow and dark dust silhouettes. Bottom: after subtracting 0.0587 times blue, only the emission in the two nebulae stands out from a nearly even background

You can also see what subtraction doesn’t fix: the faint vertical bands and the brighter lower-left corner are still there. They aren’t in the blue image, so they don’t cancel.

How much of it was continuum?

With kk known, you can calculate what share of the narrowband light was continuum. These are fresh measurements on the starless images, above the darkest 2 % of the field:

whole field brightest 5 % of the narrowband
Lobster, Hα 15 % 12 %
Lobster, OIII 54 % 38 %
SMC, Hα about 60 % about 30 %
SMC, OIII about 60 % about 25 %

The SMC numbers are rougher. In such a crowded field I found only 140 isolated stars, and their kk differed by 7–9 % from the values used in the image.

So the same step can be almost optional in one image and essential in the next. The Lobster’s Hα is mostly real. The SMC is a galaxy, and its own broadband glow fills the frame. And OIII is often the weaker line, so the same amount of continuum takes a bigger share of it.

The same problem in OIII: a teal background

With Hα the background turns red. OIII goes into green and blue, so there the same problem gives a teal background. This is the Lobster field, with the OIII added in a way that shows it clearly:

Four colour versions of the Lobster field. RGB only: red nebulae in a brown star field. With unsubtracted OIII: the whole Milky Way turns teal. With subtracted OIII: less teal, but still a cast and more noise. Subtracted, denoised and gated: white-blue OIII only in the nebula cores, with the brown star field back

The same OIII strength in the last three versions. These are quick starless previews to show the effect, not the final look.

Without subtraction (top right) the whole Milky Way turns teal. Subtraction (bottom left) removes a lot of that, but not all of it: some faint residue is left and the noise has gone up. The last step (bottom right) is what makes it usable:

  1. Denoise the subtracted image, still linear. NoiseXTerminator brought the OIII noise down by a factor of 3.3.
  2. Gate it: smooth a copy, and let the OIII through only where that copy is clearly above zero. Below the threshold it’s set to zero, so residue and noise don’t enter the colour image.

With the threshold I used, the gate opens on only about 3 % of the field. That’s an honest reflection of how little OIII there is, and a choice too: very faint real OIII below the threshold is lost.

Remove the stars first

The formula doesn’t care about stars: they’re continuum, so they should vanish. In practice they don’t, because the stars in the two images never have exactly the same shape.

RCW 106 in three versions. Top: Hα with a dense star field. Middle: continuum subtracted with the stars left in, which turns them into black dots and rings all over the nebula. Bottom: subtracted on starless images, with clean filaments

RCW 106. The Hα came from a 107 mm refractor, the colour from an 80 mm one, so the star shapes differ even after deconvolution.

So my order is: measure kk on the images with stars, run StarXTerminator on both, and subtract the starless versions. It isn’t perfect either. A bright star that StarXTerminator leaves partly behind becomes a hole or a bright spot after subtraction. Look for those, and patch them before you combine.

There’s one exception. On Barnard’s Galaxy, StarXTerminator moved up to 98 % of the light of some small H II regions into the star image, because at that scale they look like stars. There I subtracted with the stars in, and kept only hand-picked apertures around the knots. Before subtraction, the Hα followed the galactic cirrus in front of the galaxy, with a correlation of 0.31. After it: −0.01.

Without an Hα filter at all

This works in reverse too. A camera modified for astronomy records Hα in its red channel, along with the continuum. If you can predict the continuum from green and blue, what’s left in red is Hα.

I did that for the Prawn Nebula, where I had no Hα data. From about 23,000 stars: R = 1.85 G − 0.82 B.

The Prawn Nebula. Top: the starless red channel, with a general glow over the whole field. Bottom: after subtracting the continuum predicted from green and blue, with a darker background and clearer filaments

The catch is noise: subtracting two more noisy channels raised the noise at scales of a few pixels to about 1.5 times that of the red channel. The solution was to use the single-colour version (R − 1.10 G) at small scales, and the accurate two-colour correction only above about 8 pixels. That kept the noise at the single-colour level.

A stock camera of the same type helps as well. For the Flaming Carina field I had red data from both a stock and a modified D600: the stock camera blocks most of the Hα, so its red channel is nearly pure continuum.

Mistakes I made along the way

Fitting k on the image. It’s tempting to plot narrowband against broadband for the whole image and take the slope. But Hα sits in the red channel as well, so the nebula pulls the slope up. Testing it now on the Lobster’s Hα gives 0.46, nine times the star value. On the Flaming Carina it went wrong the other way: the fit gave 0.48 and the stars 0.83, so about 40 % of the continuum was left in. The result even looked better on paper, because leftover continuum counted as signal. On NGC 1313, noise in the reference flattened the fit: 0.062, where the stars said 0.105.

Clipping the negatives. After subtraction, half of the background noise is below zero, and that’s fine. PixelMath saved my M16 result clipped at zero: 12 % of the pixels were gone, and the noise was no longer symmetrical. Add a small pedestal, and remove it later.

Subtracting the line itself. A modified camera’s red channel holds Hα, so k×Rk \times R also takes away some real Hα. In the Lobster that was 10 % of the Hα, and 2 % of the OIII. Since it’s a constant fraction, it hardly changes how the image looks, and you can divide it back out.

Assuming it always helps. On the Eagle and Omega mosaic I subtracted the OIII but left the Hα as it was. I tested an Hα version later, and it gained nothing: after background removal most of the smooth continuum was already gone, the nebula hardly changed, and the star clouds only got bluer.

Expecting it to solve the colour. On NGC 300 the subtraction was fine, but the first result still looked like blobs of paint on the galaxy. How strongly you add the line, and into which channels, is a separate choice.

Step by step in PixInsight

  1. Stack, register narrowband and RGB onto one grid, crop, and colour-calibrate the RGB (SPCC).
  2. Measure kk on those linear images, with the stars still in: by hand on about 20 stars, or with a script (mine also subtracts, sets the zero level and checks the result). Use the red channel for Hα and the blue channel for OIII.
  3. Run StarXTerminator on both, linear.
  4. Subtract with PixelMath, with a pedestal and rescaling off. Use channel 0 for red and 2 for blue:
Ha_starless - 0.0515*RGB_starless[0] + 0.001
  1. Check: no negative or positive dust clouds, no black holes in the nebulae, no pixels at exactly 0. If there are, the pedestal is too small or kk is off.
  2. Set the zero point on the darkest real background, and fix any remaining gradient only if you’re sure it isn’t faint nebula.
  3. Denoise, gate, and add it to the colour image. Keep the pedestal in mind: subtract it first.

If you’re in doubt about kk, fine-tune it by eye with the silhouette test: raise it until the dark clouds neither stand out dark nor bright. That’s harder in fields where real emission follows the dust, so stay close to the value the stars gave you.

When do you need it?

  • Any time you add Hα or OIII to a colour image and the background takes on its colour.
  • Galaxies: nearly always. Without it, adding Hα reddens the whole disk instead of just the H II regions.
  • OIII or other weak lines in the Milky Way: yes.
  • Broad filters: more than narrow ones. kk scales with the filter width, so a 3 nm filter lets in far less continuum than a 12 nm one, and the wide passbands of many dual-band filters let in even more.
  • Bright Hα nebulae on a dark background: the gain is small.
  • A pure narrowband palette without broadband data: you can’t do it properly, and for strong emission you probably don’t have to.

Conclusion

Continuum subtraction is one line of PixelMath. The work is in the number kk, and the stars in your image hand you that number for free. Check it on the dark clouds, accept that the result is noisier, and only let through what’s clearly there.

For me the real gain wasn’t a prettier Hα image. It was knowing that what I call Hα or OIII in my colour image is gas, and that the background isn’t red because of something I added myself.

Comments

Loading comments…

Leave a comment

Comments appear once I've read them. No account needed; only your name and comment are shown.