This section presents extended modules designed for editing (correcting) SPM data. Using simple data editing tools presented in chapter Data Edit and Correction it is possible to correct many local scanning defects that can be found on SPM images. There are also many error sources within SPM methods that lead to global errors, like low frequencies modulated on the data or data drift in the slow scanning axis.

→ →

Compensate Drift calculates and/or corrects drift in the fast scanning axis (horizontal). This adverse effect can be caused by thermal effects or insufficient mechanical rigidity of the measuring device.

The drift graph, which is one of possible outputs, represents the horizontal shift of individual rows compared to a reference row (which could be in principle chosen arbitrarily, in practice the zero shift is chosen to minimize the amount of data sticking out of the image after compensation), with the row y-coordinate on the abscissa.

The drift is determined in two steps:

- A mutual horizontal offset is estimated for each couple of rows not more distant than Search range. It is estimated as the offset value giving the maximum mutual correlation of the two rows. Thus a set of local row drift estimations is obtained (together with the maximum correlation scores providing an estimate of their actual similarity).
- Global offsets are calculated from the local ones. At present the method is very simple as it seems sufficient in most cases: local drift derivatives are fitted for each row onto the local drift estimations and the global drift is then obtained by integration (i.e. summing the local drifts).

Option Exclude linear skew subtracts the linear term from the calculated drift, it can be useful when the image is anisotropic and its features are supposed to be oriented in a direction not paralled to the image sides.

→ →

One excellent way of removing frequency based of noise from an image is to use Fourier filtering. First, the Fourier transform of the image is calculated. Next, a filter is applied to this transform. Finally, the inverse transform is applied to obtain a filtered image. Gwyddion uses the Fast Fourier Transform (or FFT) to make this intensive calculation much faster.

Within the 1D FFT filter the frequencies that should be removed from spectrum (suppress type: null) or suppressed to value of neighbouring frequencies (suppress type: suppress) can be selected by marking appropriate areas in the power spectrum graph. The selection can be inverted easily using the Filter type choice. 1D FFT filter can be used both for horizontal and vertical direction.

→ →

2D FFT filter acts similarly as the 1D variant (see above) but using 2D FFT transform. Therefore, the spatial frequencies that should be filtered must be selected in 2D using mask editor. As the frequencies are related to center of the image (corresponding to zero frequency), the mask can be snapped to the center (coordinate system origin) while being edited. There are also different display and output modes that are self-explanatory – image or FFT coefficients can be outputted by module (or both).

→ →

Affine distortion in the horizontal plane caused by thermal drift is common for instance in STM. If the image contains a regular structure, for instance an atomic lattice of known parameters, the distortion can be easily corrected using this function.

The affine distortion correction requires to first select the distorted lattice in the image. This is done by moving the lattice selection on the preview with mouse until it matches the regular features present in the image. For images of periodic lattices, it is usually easier to select the lattice in the autocorrelation function image (2D ACF). Also, only a rough match needs to be found manually in this case. Button refines the selected lattice vectors to the nearest maxima in autocorrelation function with subpixel precision.

The correct lengths of the lattice vectors
a_{1} and a_{2}
and the angle φ between them, entered to
the dialog, determine the affine transformation to perform. A few common
lattice types (such as HOPG surface) are offered predefined, but it is
possible to enter arbitrary lengths and angle.

It should be noted that the correction method described above causes all lateral scale information in the image to be lost because the new lateral scale is fully determined by the correct lattice vectors. This is usually the best option for STM images of known atomic lattices, however, for a general skew or affine correction it can be impractical. Therefore, the dialog offers three different scaling choices:

- Exactly as specified
Lattice vectors in the corrected image will have the specified lengths and angle between them. Scale information of the original image is discarded completely.

- Preserve area
Lattice vectors in the corrected image will have the specified ratio of lengths and angle between them. However, the overall scale is calculated as to make the affine transformation area-preserving.

- Preserve X scale
Lattice vectors in the corrected image will have the specified ratio of lengths and angle between them. However, the overall scale is calculated as to make the affine transformation preserve the original x-axis scale. This is somewhat analogous to the scale treatment in Drift compensation.

→ →

General distortion in the horizontal plane can be compensated, or created, with Polynomial distortion. It performs transforms that can be expressed as

where P_{x} and
P_{y} are polynomials up to the third total
order with user-defined coefficients. Note the direction of the
coordinate transform – the reverse direction would not guarantee an
unambiguous mapping.

The polynomial coefficients are entered as scale-free, i.e.
as if the coordinate ranges were always [0, 1]. If
Instant updates are enabled, pressing
**Enter** in a coefficient entry (or just leaving moving
keyboard focus elsewhere) updates the preview.

→ →

Extraction of data along circular features, curved step edges and other arbitrarily shaped smooth paths can be a useful preprocessing step for further analysis. Function “straightenig” the input image along a spline path specified using a set of points on the image.

creates a new image by
The points defining the path can be defined on the preview image.
Each control point can be moved with mouse. Clicking into the empty
space adds a new point, connected to the closer end of the path.
Individual points can be deleted by selecting them in the point list in
the left part of the dialogue and pressing **Delete**.

The shape of the extracted area is controlled by the following parameters:

- Thickness
The width of the extracted image, denoted by the perpendicular marks on the path. This is the full width, i.e. the distance to each side of the path is half of the thickness.

- Slackness
Parameter influencing the shape of the path between the control points. It can be visualised as the slackness of a string connecting the control points. For zero slackness the string is taut and the path is formed by straight segments. Increasing slackness means decreasing tensile stress in the string, up to slacknes of unity for which the string is stress-free. Values larger than unity mean there is an excess string length, leading to compressive stress.

- Closed curve
If this option is enabled the path is closed, allowing the extraction of ring-shaped areas (for instance). Otherwise the path has two free ends.

For certain combinations of path shape and thickness the resulting image can contain regions that lie outside the original image. Such regions are masked in the output and filled with a neutral value.

→ →

Function Straighten Path stores the selected path with the data so that it can be recalled later. If you need the coordinates and/or directions corresponding to the straightened image for further processing you can use .

The function plots the real coordinates or tangents to the path, i.e. the direction cosines and sines, as graphs. Coordinates are selected as X position and Y position; directions are selected as X tangent and Y tangent. The number of points of each graph curve is the same as the number of rows of the straightened image created by Straighten Path and there is one-to-one correspondence between the rows and graph curve points.

→ →

Calculates denoised image on the basis of two measurements of the same area – one performed in x direction and one in y direction (and rotated back to be aligned the same way as the x direction one). It is based on work of E. Anguiano and M. Aguilar (see [1]). Module performs FFT of both images, combines information from both images in reciprocal space, and then performs backward FFT in order to get denoised image. It is useful namely for large scars and fast scanning axis stripes removal.