You are here: Home / Publications / Nebulosity Filter

Nebulosity Filter

Mike Irwin (Cambridge)

Most object cataloguing software works by generating a "smooth" local single pass map of the background, or sky, on some specified scale and then proceeds to detect significant features, or objects, with respect to this local background estimate (e.g. Irwin 1985; Bertin & Arnouts 1996). The most common method used to estimate a local background is to split the image into a coarse grid of background pixels (e.g. each with, say, ~100x100 image pixels), robustly estimate some sort of clipped "average" background value, and then construct an interpolated "smooth" background at the original pixel sampling.  This method works extremely well in most cases and provides an excellent compromise between tracking (following) small scale background variations -- which are robust against both systematic and rms noise problems -- and being executable in an efficient and routine manner.

However, in certain situations, particularly in regions of bright, spatially-varying nebulosity, traditional background following is insufficient.  This is illustrated in Figure 1, which shows WFCAM K-band observations of M17, taken as part of the UKIDSS GPS survey. Panel (a) shows the original image, panel (b) the view as seen by object detection software after removing the varying background using a standard grid-based approach, in this case with the CASU pipeline default 128x128 pixel (25x25 arcsec) sub-sampling for 2x2 interleaved data.

To some extent using ever finer grids alleviates the problems seen in these background-subtracted data.  However, one quickly hits the buffer of introducing significant magnitude-dependent systematic errors in object photometry caused by dark, over-corrected halos around brighter objects (see e.g. Figure 1(c), which shows the results of using a 64x64 pixel grid).

A similar, more exaggerated problem occurs in conventional unsharp masking, due to the (even more) inherently linear nature of the procedure.  However, unsharp masking does have one excellent attribute: a superbly flat background (Figure 1(d))!

Conventional unsharp masking works by subtracting a smoothed version of an image from itself (usually the image is smoothed using a Gaussian kernel).  The smoothing, or convolution, suppresses the higher spatial frequency components of the image; the difference image then does the opposite and suppresses the lower frequency components. Any similar filter in Fourier space has the same effect and the same issues, namely that some part of the lower spatial frequency components of objects of interest in the image also get affected. The outcome is typically a dark halo (a hole) in the background around each object.  These halos are particularly obvious around brighter objects, and lead to systematic problems with the photometry.

However, the difference image background is beautifully flat over most of the area (apart from the induced "ringing" artifacts around the brighter objects).  A simple improvement is to swap the linear smoothing operator for a non-linear scheme based, for example, on non-parametric two-dimensional median filters.  In practice something like a bi-linear median filter (a cross-shape) followed by a simple linear box-car filter (also a cross-shape) does a much better job of separating components of the image that are varying on different scales.  The "negative-going" artifacts around fainter objects do then disappear quite effectively, although the dark halos around bright objects are still apparent (albeit at a much lower level than before).

The next stage in the improvement is based on the fact that the difference image is mostly comprised of a flat background + noise + objects with adjacent artifacts. Both the background level and the equivalent rms noise can be robustly estimated using iteratively clipped medians and "MADs" (Median of Absolute Deviation from median, e.g. Hoaglin, Mosteller and Tukey 1983).  The remaining features, the objects and artifacts, can then be masked out using k-sigma clipping and the filtering operation repeated.  In practice this procedure converges within a few iterations and effectively decouples features within the image into large scale structures (the background and/or most of the nebulosity) and small scale structures (the objects of interest).  This is illustrated in Figure 2, where the image has been spatially split into features smaller in scale than ~10 arcsec (the left-hand panel) and greater in scale than ~10 arcsec (the right-hand panel).

Object detection and parametrisation in the "nebulosity filtered" image is now much simpler and more reliable.  Tests on astrometry, photometry and morphological shape discriminators suggest the process improves all three and has a negligible impact on biassing the photometry of brighter point sources until they have already saturated. For large, extended sources of similar or larger scale to the filtering scale length, this is obviously not the case -- but then even conventional survey-style object cataloguing has problems with these objects.

Our nebulosity filtering method can be applied to almost any type of background variation, since the non-linear nature of the filtering even allows for good tracking of step changes in the background, e.g. as seen in reflection halos around bright stars.  Indeed, the filtering can convert unusable images into something you might even want to do photometry on -- as in the MegaCam image of the region around Beta Andromedae (Mirach) and Mirach's ghost, NGC 404 (Figure 3).

Figure 1: A WFCAM K-band imaging of M17.  (a) the original image; (b) the image after removing the varying background using a standard grid-based approach (128x128 pixel grid); (c) after removing the background using a smaller 64x64 pixel grid; (d) the effects of unsharp-masking.

Figure 2: Spatially splitting the image of M17 up into small-scale features (the stars) and large-scale features (the background and nebulosity) using iteratively clipped non-linear filtering (see text for details).

Figure 3: Images of the bright star Beta Andromedae (Mirach), before (left) and after (right) nebulosity filtering.  Mirach's ghost, NGC404, can be seen much more clearly in the right-hand panel. Note particularly, the absence of dark halos around other saturated stars and the still intact edges and level changes around Mirach.

See attachment for figures.

Original text published in the UKIRT Newsletter #26.


  • Bertin & Arnouts 1996, A&AS, 117, 393
  • Irwin 1985, MNRAS, 214, 575
  • Hoaglin, Mosteller & Tukey 1983, in Understanding robust and exploratory data anlysis, Wiley