Image processing filters

Convolution filters

These consist of simple 3x3 or 5x5 matrix convolution filters.  These filters are applied by replacing each pixel intensity by a weighted average of its neighbouring pixels.  The weights that are applied to the neighbouring pixel intensities are contained in a matrix called the convolution matrix.  In Pyxis, two convolution matrices are applied sequentially to each pixel, these are referred to as the primary and secondary matrices.  The user can define custom 3x3 or 5x5 convolution matrices or use the provided predefined filter matrices for the following convolution filters;

Low Pass:  This filter strongly weights the values in neighbouring pixels, so the effect is similar to computing a local average.  High frequency components are attenuated by this filter.
High Pass:  The high pass filter uses negative weighting coefficients for the neighbouring pixels, this effectively enhances regions of high intensity gradient in the image so that finer details are emphasized.
Laplacian:  This filter is similar to the high-pass filter, however the sum of the weighting coefficients is zero.  This filter emphasizes contours in the image.
Sobel: This is a very strong contour emphasizing filter.
Prewitt:  Similar to Sobel filter.


Minimal/Maximal filters

These are statistical filters that replace each pixel value with either the minimal or maximal value from the set of nearest neighbour pixels.  Four sampling configurations for the pixels can be selected by clicking on the desired sampling configuration (shown on the right).  A minimal filtering step is referred to as "erosion" because it reduces the size of features in the image.  A maximal filtering operation is referred to as an "expansion" because it has the opposite effect on features in the image.  Generally the minimal and maximal filters are not used alone, but instead a maximal filtering step is followed by minimal filtering step; the effect is to strongly attenuate very sharp spikes in the image.  The case of erosion followed by expansion is referred to as "closing", whereas "opening" corresponds to the reverse filtering order.


Unsharp mask

This is perhaps the most powerful filter for use in planetary image processing.  The idea is to create a strongly low-pass filtered mask from the image that only contains the slow variations in the image contrast and subtract it from the original image.  The effect of this operation is to very stongly enhance small contrast variations in the image and attenuate less interesting low frequencies, as are due for example to uneven illumination of the planet surface.  In Pyxis the unsharp mask can be created using either gaussian cross-convolution or local averaging (the gaussian convolution is generally preferred).  Weighting factors for the mask and original image must usually be adjusted to obtain optimum results for every different case, although it is generally preferrable to use similar settings when processing the individual colour channels of an object.


Gaussian cross-convolution

This convolution technique applies a gaussian profile weighting factor first to the x-direction in the image, followed by the y-direction in the image.  Gaussian cross-convolution is a very quickly computed smoothing filter; the extent of the smoothing is controlled by the width of the applied gaussian profile.
 

Local average

Replaces the pixel value by the average over a given number of nearest neighbour pixels.  The pixel radius out to which pixels are included in the average determines the amount of smoothing applied. 


Local median

This is probably the most powerful tool for removing large noise spikes in the image.  This is a statistical filter similar to the minimal/maximal filters in that the pixels in the neighbourhood of the pixel being processed are sampled and sorted in terms of intensity.  The median filter selects median intensity (the intensity for which half the samples have greater intensity and half the samples have lower intensity) in the sampled set of pixels.  The effect is to reject strong outlier low or high pixel intensities while having a "relatively" small effect on the image details compared to other smoothing techniques.  The median filter is particularly useful for removing cosmic ray spikes from images that have relatively large stellar images on the CCD.  The disadvantage of this technique is that faint stars are often removed from the image.


Threshold and bias subtraction

Thresholding consists of constraining the pixel values to remain within certain limits.  Bias subtraction subtracts a fixed bias level from the image.


Subtracting a model sky

It is often useful to subtract a planar gradient from the image to try to remove sky effects that cannot be removed by flat fielding (for example lunar glow in one corner of the image).  The sky-model tool estimates the slope of the sky background in the x and y directions so that the planar component of the sky background can be subtracted.  Note that when the x-slope and y-slope are zero, this simply corresponds to a fixed bias subtraction.


Fourier transform low or high pass

The Fourier transform (FT) filter converts the image to the spatial frequency domain using a fast Fourier Transform algorithm.  To do this efficiently, the image is first converted to a square domain by padding the edges of the image with the average value of the image intensity.  The FT returns the complex coefficients for each 2D spatial frequency in the image up to Nyquist (1/2 the image width).  When the FT filter tool is invoked, the FT is automatically computed and the FT of the image is displayed (actually, what is displayed is the square modulus of the complex fourier coefficients).  The center of the FT image represents the lowest spatial frequencies, whereas the edge represents the higher frequencies.  Clicking and dragging on the image causes a circle of variable size to be drawn, centered on the image image center (i.e. the frequency origin where, fx = 0 and fy = 0).  This circle represents the cutoff frequency to be used in the filtering.  Alternatively, the cutoff frequency may be entered manually in an edit box below the image.

The cutoff is "apodized" or smoothed by using a gaussian edge profile for the cutoff or "aperture function" - in this case a circular aperture in frequency space.  The purpose of the gradual cutoff is to avoid "ringing" in the image effectively caused by the oscillatory sin(x)/x response of the FT to a 2D intensity profile that is exactly 1 within a certain radius and 0 without.  Note that the FT of a Gaussian is another Gaussian, so that oscillations are suppressed by Gaussian and other smoothly varying aperture functions.  Once the filtering parameters are selected, click "preview" to compute the inverse FT of the modified image FT and thereby obtain the filtered image.  If excessive ringing is present (this appears as rings around bright stars), increase the apodization width until the ringing is suppressed to an acceptable level.