Filters and Presentations

Basic Filters Tool

The Basic Filters tool lets you apply several simple filters to your image. This can be very useful for data denoising; however, the real measured data will get altered in the process, so great care should be taken not to destroy important features of the image.

  • Mean filter – takes the mean value of neighborhood of the filtered value as the value.
  • Median filter – takes the median value of neighborhood of the filtered value as the value.
  • Conservative denoise filter – checks whether the value is not extreme within the neighborhood. If yes, filter substitutes the value by of the next highest (lowest) value.
  • Kuwahara filter – is an edge-preserving smoothing filter.
  • Minimum filter – also known as erode filter, replaces values by minimum found in neighborhood.
  • Maximum filter – also known as dilate filter, replaces values by maximum found in neighborhood.
  • Dechecker filter – a smoothing filter specially designed to remove checker pattern from the image while preserving other details. It is a convolution filter with kernel
    Dechecker filter 5 × 5 coefficient matrix
  • Gaussian filter – a smoothing filter, the size parameter determines the FWHM (full width at half maximum) of the Gaussian. The relation between FWHM and σ is
    FWHM-sigma relation for Gaussian

Tip

By default, these filters will be applied to the entire image. However, you can apply a filter to a specific region within your image by selecting it with the mouse. This can be useful for correcting badly measured areas within a good image. To apply a filter to the entire image again, just click once anywhere within the image window.

Figure 4.7. Filtering screenshot

Filtering screenshot

Moreover, there are more denoising functions in Gwyddion, for example DWT denoising and FFT filtering. For details see section Extended Data Edit.

If you need to only suppress some values in the SPM data that are obviously wrong, you can also try the Mask of Outliers module and the Remove Data Under Mask module. For details see section Data Edit.

Convolution

Data ProcessIntegral TransformsConvolution Filter

Convolutions with arbitrary kernels up to 9 × 9 can be performed with the Convolution Filter module.

The Divisor entry represents a common factor all the coefficients are divided before applying the filter. This allows to use denormalized coefficients that are often nicer numbers. The normalization can be also calculated automatically when automatic is checked. When the sum of the coefficients is nonzero, it makes the filter sum-preserving, i.e. it the factor normalizes the sum of coefficients to unity. When the sum of the coefficients is zero, the automatic factor is simply let equal to 1.

Since many filters used in practice exhibit various types of symmetry, the coefficients can be automatically completed according to the selected symmetry type (odd, even). Note the completion is performed on pressing Enter in the coefficient entry.

In a fresh installation only a sample Identity filter is present (which is not particularly useful as it does nothing). This filter cannot be modified, to create a new filter use the New button on the Presets page.

Presentations

Data ProcessPresentation

Presentations are special filters that output their results into a separate layer that displays on top of the original data. Unlike the filters mentioned above, presentation filters preserve the measured data. This allows the user to safely apply various data visualizations. The other data processing modules and tools will still operate on the original data. To remove a presentation, just right click on the data window, and select Remove Presentation.

The Presentation menu contains a few basic presentation operations:

Attach Presentation

Data ProcessPresentationAttach presentation

Attaches other data (height or other physical quantity field) as a presentation to the actual data. Note that this useful option can be particularly confusing while evaluating anything from the data as all the computed values are evaluated from the data (not from the presentation, even if it looks like data).

Remove Presentation

Data ProcessPresentationRemove presentation

Removes presentation from the actual data window.

Extract Presentation

Data ProcessPresentationExtract presentation

Extracts presentation from the actual data window making copy of the presentation as a new channel in the same file. In this way one can get presentation data for further processing. Note however, the extracted data have no absolute scale information (the range is always [0, 1]) as presentation often help to visualize certain features, but the produced values are hard or impossible to assign any physical meaning to.

Figure 4.8.  Presentation examples: (a) original data, (b) shading, (c) vertical Prewitt gradient, (d) Canny edge detection, (e) local non-linearity edge detection, (f) local contrast improvement.

Illustration of selected presentation filters

Shading Presentation

Data ProcessPresentationShading

Simple and very useful way of seeing data as illuminated from some direction. The direction can be set by user. It is also possible to mix the shaded and original images for presentational purposes (the resulting image is meaningless from the physical point of view).

Gradient Detection Presentations

Data ProcessPresentationGradient...

Sobel horizontal and vertical gradient filter and Prewitt horizontal and vertical gradient filter create similar images as shading, however, they output data as a result of convolution of data with relatively standardized kernel. Thus, they can be used for further presentation processing for example. The kernels for horizontal filters are listed below, vertical kernels differ only by reflection about main diagonal.

Edge Detection Presentations

Data ProcessPresentationEdge Detection

One is often interested in the visualization of the discontinuities present in the image, particularly in discontinuities in the value (zeroth order) and discontinuities in the derivative (first order). Although the methods of location of both are commonly referred to as “edge detection” methods, these are actually quite different, therefore we will refer to the former as to step detection and to the latter as to edge detection. Methods for the detection of more specific features, e.g. corners, are commonly used too, these methods usually are of order zero.

The order of a discontinuity detection method can be easily seen on its output as edge detection methods produce typical double edge lines at value discontinuities as is illustrated in the following figure. While the positions of the upper and lower edge in an ideal step coincide, real-world data tend to actually contain two distinct edges as is illustrated in the picture. In addition, finding two edges on a value step, even an ideally sharp one, is often an inherent feature of edge detection methods.

Figure 4.9.  Step versus edge in one dimension.

One-dimensional step and edge schematic image

The following step and edge detection functions are available in Gwyddion (the later ones are somewhat experimental, on they other hand they usually give better results than the well-known algorithms):

Canny

Canny edge detector is a well-known step detector can be used to extract the image of sharp value discontinuities in the data as thin single-pixel lines.

Laplacian of Gaussians

Laplacian presents a simple convolution with the following kernel (that is the limit of discrete Laplacian of Gaussians filter for σ → 0):

Zero Crossing

Zero crossing step detection marks lines where the result of Laplacian of Gaussians filter changes sign, i.e. crosses zero. The FWHM (full width half maximum) of the Gaussians determines the level of details covered. Threshold enables to exclude sign changes with too small absolute value of the neighbour pixels, filtering out fine noise. Note, however, that for non-zero threshold the edge lines may become discontinuous.

Step

A step detection algorithm providing a good resolution, i.e. sharp discontinuity lines, and a good dynamic range while being relatively insensitive to noise. The principle is quite simple: it visualizes the square root of the difference between the 2/3 and 1/3 quantiles of the data values in a circular neighbourhood of radius 2.5 pixels centered around the sample.

RMS

This step detector visualizes areas with high local value variation. The root mean square of deviations from the mean value of a circular neighbourhood of radius 2.5 pixels centered around each sample is calculated and displayed.

RMS Edge

This function essentially postprocesses RMS output with a filter similar to Laplacian to emphasize boundaries of areas with high local value variation. Despite the name it is still a step detector.

Local Non-Linearity

An edge detector which visualizes areas that are locally very non-planar. It fits a plane through a circular neighbourhood of radius 2.5 pixels centered around each sample and then calculates residual sum of squares of this fit reduced to plane slope, i.e. divided by 1 + bx2 + by2 where bx and by are the plane coefficients in x and y directions, respectively. The square root is then displayed.

Inclination

Visualizes the angle ϑ of local plane inclination. Technically this function belongs among step detectors, however, the accentuation of steps in its output is not very strong and it is more intended for easy visual comparison of different slopes present in the image.

Figure 4.10.  Comparison of step and edge detection methods on several interesting, or typical example data. Canny and Zero crossing are step detectors that produce one pixel wide edge lines, Step and Inclination are step detectors with continous output, Local nonlinearity is an edge detector – the edge detection can be easily observed on the second and third row. Note zero crossing is tunable, it parameters were chosen to produce reasonable output in each example.

Comparison of step and edge detection methods on several images

Local Contrast

Data ProcessPresentationLocal contrast...

A method to visualize features in areas with low and high value variation at the same time. This is achieved by calculation of local value range, or variation, around each data sample and stretching it to equalize this variation over all data.

Logscale

Data ProcessPresentationLogscale

Logarithmic scale is used for false colors data presentation.