Data Edit and Correction

There are several modules that enable direct or indirect editing of the SPM data. In principal, most of the data processing modules change the data in one way or another. However, in this section we would like to describe the modules and tools that are specifically designed to correct local defects in an image. The functions below remove bad data from an image, and then fill it in using an interpolation algorithm.

Remove Spots Tool

The Remove Spots tool can be used for removing very small parts of the image that are considered a scanning error, dust particle or anything else that should not be present in the data. Note that doing so can dramatically alter the resulting statistical parameters of the surface, so be sure not to remove things that are really present on the surface.

While using this tool you can pick up position of the spot to magnify its neighbourhood in the tool window. Then, in the tool window, select a rectangle around the area that should be removed. You can then select one of several interpolation methods for creating data in place of the former spot:

  • Hyperbolic flatten - uses information from selected area boundaries to interpolate the information inside area.
  • Pseudo-Laplace and Laplace solver - solves Laplace equation to calculate data inside area; the boundary is treated as virtual source.
  • Fractal correction - uses whole image to determine fractal dimension. Then tries to create randomly rough data that have the same fractal dimension and put them into the area.

Clicking Apply will execute the selected algorithm.


Spot removal will only work for regions of size 64 × 64 pixels or smaller. To remove larger regions, create a mask using the Mask Editor tool, then use Data ProcessCorrect DataRemove Data Under Mask.

Remove Grains Tool

This simple tool removes manually selected connected parts of mask or interpolates the data under them, or possibly both. The part of mask to remove is selected by clicking on it with left mouse button.

Remove Scars

Data ProcessCorrect DataRemove Scars

Scars (or stripes, strokes) are parts of the image that are corrupted by a very common scanning error: local fault of the closed loop. Line defects are usually parallel to the fast scanning axis in the image. This function will automatically find and remove these scars, using neighbourhood lines to fill-in the gaps. The method is run with the last settings used in Mark Scars.

Mark Scars

Data ProcessCorrect DataMark Scars

Similarly, the Mark Scars module can create a mask of the points treated as scars. Unlike Remove Scars which directly interpolates the located defects, this module lets you interactively set several parameters which can fine-tune the scar selection process:

  • Maximum width – only scars that are as thin or thinner than this value (in pixels) will be marked.
  • Minimum length – only scars that are as long or longer than this value (in pixels) will be marked.
  • Hard threshold – the minimum difference of the value from the neighbouring upper and lower lines to be considered a defect. The units are relative to image RMS.
  • Soft threshold – values differing at least this much do not form defects themselves, but they are attached to defects obtained from the hard threshold if they touch one.
  • Positive, Negative, Both – the type of defects to remove. Positive means defects with outlying values above the normal values (peaks), negative means defects with outlying values below the normal values (holes).

After clicking Ok the new scar mask will be applied to the image. Other modules or tools can then be run to edit this data.

Scrars removal example

Scars marking and removal example: (a) original data with defects, (b) data with marked deffects, (c) corrected data.

Remove Data Under Mask

Data ProcessCorrect DataRemove Data Under Mask

This function substitutes the data under the mask by the solution of solving the Laplacian equation. The data values around the masked areas define the boundary conditions. The solution is calculated iteratively and it can take some time to converge.

Fractal Correction

Data ProcessCorrect DataFractal Correction

The Fractal Correction module, like the Remove Data Under Mask module, replaces data under the mask. However, it uses a different algorithm to come up with the new data: The fractal dimension of the whole image is first computed, and then the areas under the mask are substituted by a randomly rough surface having the same fractal dimension. The root mean square value of the height irregularities (roughness) is not changed by using this module.


This calculation can take some time, so please be patient.


Running this module on data that do not have fractal properties can cause really unrealistic results and is strictly not recommended.

Mask of Outliers

Data ProcessCorrect DataMask of Outliers

This module creates mask of areas in the data that not pass the criterion. All the values above and below this confidence interval are marked in mask and can be edited or processed by other modules afterwards.

Line Correction

Profiles taken in the fast scanning axis (usually x-axis) can be mutually shifted by some amount or have slightly different slopes. The basic line correction functions deal with this type of discrepancy. Several functions can be used: The Polynomial and Path level tools and then several procedures under Data ProcessCorrect Data menu.

The Polynomial tool fits each horizontal or vertical line by a polynomial up to the third order and then subtracts the fitted polynomial – a very frequently used function in basic processing of raw SPM data. It also permits to exclude or include selected area from the fit. The inclusion or exclusion only applies to the lines interseting the selected area. Other lines are always fitted using all data values.

Line correction functions in Correct Data perform only horizontal line corrections, therefore one has to rotate the image to perform column-wise correction. They include:

  • Match Line Correction,
  • Median Line Correction,
  • Modus Line Correction, and
  • Median Difference Line Correction,
  • Step Line Correction.

The first three are very similar, they all align rows of the data field to minimize some quantity. As the names indicate, Median Line Correction matches line medians while Modus Line Correction attempts to match line (pseudo)modus. Match Line Correction minimizes certain line difference function that gives more weight to flat areas and less weight to areas with large slopes. The effect of all three functions is often very similar, although some can be more suitable for certain type of data than others.


Median line correction supports masking. If a mask is present it offers to use the data under mask for the leveling, exclude the data under mask or ignore the mask and use the entire data.

Function Median Difference Line Correction shifts the lines so that the median of differences (between vertical neighbour pixels) becomes zero, instead of the difference of medians. Therefore it better preserves large features while it is more sensitive to completely bogus lines.

Function Step Line Correction differs from the others. It attempts to identify misaligned segments within the rows and correct the height of each such segment individually. Therefore it is often able to correct data with discontinuities in the middle of a row. This function is rather experimental and the exact way it works can be subject of futher changes.

Path Leveling Tool

The Path Leveling tool can be used to correct the heights in an arbitrary subset of rows in complicated images.

First, one selects a number of straight lines on the data. The intersections of these lines with the rows then form a set of points in each row that is used for leveling. The rows are moved up or down to minimize the difference between the heights of the points of adjacent rows. Rows that are not intersected by any line are not moved (relatively to neighbouring rows).

Path Level example: (a) uncorrected data with steps that the automated method may fail to correct, two suitable leveling lines are selected; (b) the result of Path Level application with line width 5.


Data ProcessCorrect DataUnrotate

Unrotate can automatically make principal directions in an image parallel with horizontal and/or vertical image edges. For that to work, the data need to have some principal directions, therefore it is most useful for scans of artifical and possibly crystallic structures.

The rotation necessary to straighten the image – displayed as Correction – is calculated from peaks in angular slope distribution assuming a prevalent type of structure, or symmetry. The symmetry can be estimated automatically too, but it is possible to select a particular symmetry type manually and let the module calculate only corresponding rotation correction. Note if you assume a structure type that does not match the actual structure, the calculated rotation is rarely meaningful.

It is recommended to level (or facet-level) the data first as overall slope can skew the calculated rotations.

Unrotate symmetries scheme

Orientations of prevalent directions corresponding to Unrotate symmetry types.

The assumed structure type can be set with Assume selector. Following choices are possible:


Automatically detected symmetry type, displayed above as Detected.


Parallel lines, one prevalent direction.


Triangular symmetry, three prevalent directions (unilateral) by 120 degrees.


Square symmetry, two prevalent directions oriented approximately along image sides.


Rhombic symmetry, two prevalent directions oriented approximately along diagonals. The only difference from Square is the preferred diagonal orientation (as opposed to parallel with sides).


Hexagonal symmetry, three prevalent directions (bilateral) by 120 degrees.