Basic Operations

Basic geometrical operations are the core of any data processing program. Also Gwyddion has a wide set of functions for data scaling, rotation, resampling or profile extraction. In this section the main algorithms behind these functions will be described and the list of available modules will be presented.

Interpolation

A large number of the morphological operations in Gwyddion are dependent on data interpolation. As the SPM data are relatively coarsely sampled compared to measured details (full images are typically only a few hundred pixels in width and height), the interpolation method used can become critical for proper quantitative analysis of data properties. There are several interpolation methods [1] in 1D and 2D implemented in Gwyddion and the user can choose which method to use for most of the modules using interpolation.

Here, we describe 1D interpolation method principles. All implemented 2D interpolation methods are separable and thus simply composed of these 1D methods. The following interpolation method are currently available:

Round

Round interpolation (also called nearest neighbourhood interpolation) is the simplest method – it just takes round value of the expected position and finds therefore the closest data value at integer position. Its polynomial degree is 0, regularity C-1 and order 1.

Linear

Linear interpolation is a linear interpolation between the two closest data values. The value z at point of relative position x is obtained as

Linear interpolation formula

where z0 and z1 and values at the preceding and following points, respectively. Its polynomial degree is 1, regularity C0 and order 2. It is identical to the second-order B-spline.

Key

Key interpolation (more precisely Key's interpolation with a = −1/2 which has the highest interpolation order) makes use also of values in the before-preceding and after-following points z-1 and z2, respectively. In other words it has support of length 4, The value is then obtained as

Four-point interpolation weighted sum

where

Interpolation weights for Key

are the interpolation weights. Key's interpolation degree is 3, regularity C1 and order 3.

Schaum

Schaum interpolation (more precisely fourth-order Schaum) has also support of length 4. The interpolation are

Interpolation weights for Schaum

Its polynomial degree is 3, regularity C0 and order 4.

NNA

Nearest neighbour approximation is again calculated from the closest four data values but unlike all others it is not piecewise-polynomial. The interpolation weights are

Interpolation weights for NNA

for k = -1, 0, 1, 2, where r-1 = 1 + x, r0 = x, r1 = 1 − x, r2 = 2 − x. Its order is 1.

B-spline

B-spline was misimplemented up to version 2.1 (inclusive) and it blurred data. It should be avoided in these old versions. The weights are

Interpolation weights for B-Spline

However, they are not used with directly function values as above, but with interpolation coefficients calculated from function values [1]. Its polynomial degree is 3, regularity C2 and order 4.

O-MOMS

O-MOMS was misimplemented up to version 2.1 (inclusive) and it blurred data. It should be avoided in these old versions. The weights are

Interpolation weights for O-MOMS

However, they are not used directly with function values as above, but with interpolation coefficients calculated from function values [1]. Its polynomial degree is 3, regularity C0 and order 4.

Figure 4.1.  Illustration of the available interpolation types (the original pixels the interpolation is performed between are obvious on the result of Round interpolation). All images have identical false color map ranges.

2D interpolation examples

Basic 2D Data Operations

Within basic modules it is possible to perform the following operations with 2D data field:

  • Scale data using chosen result dimension and chosen interpolation method by Data ProcessBasic OperationsScale.
  • Crop data using the Crop tool, either in place or putting the result to a new channel (with Create new channel). With Keep lateral offsets option enabled, the top left corner coordinates of the resulting image correspond to the top left corner of the selection, otherwise the top left corner coordinates are set to (0, 0).
  • Rotate data by 90 degrees or by user-specified amount using some of the rotate functions: Data ProcessBasic OperationsRotate clockwise, or Data ProcessBasic OperationsRotate anticlockwise, or Data ProcessBasic OperationsRotate.
  • Flip data horizontally (i.e. about the vertical axis) and vertically (i.e. about the horizontal axis) with Data ProcessBasic OperationsFlip Horizontally and Data ProcessBasic OperationsFlip Vertically, respectively.
  • Flip data about the centre with Data ProcessBasic OperationsFlip Both.
  • Invert data about the mean value the Invert Value function: Data ProcessBasic OperationsInvert.
  • Upsample data to make pixels square with Data ProcessBasic OperationsSquare Samples. Most scans have pixels with 1:1 aspect ratio, therefore this function has no effect on them.

Moreover, calibration module can be used for changing the information about image physical dimensions and changing the data values calibration: Data ProcessBasic operationsCalibrate.

Reading Values

The simpliest method of reading values is to place the mouse cursor over the point you want to read value of. The coordinates and/or value is then displayed in the statusbar. This method works both with data windows and graph windows.

Read Value Tool

Tool Read Value offers more value reading posibilities: It displays coordinates and values of the last point of the data window the mouse button was pressed. It can avergae the value from a circular neighbourhood around the selected point, this is controlled by option Averaging radius. When the radius is 1, the value of a single pixel is displayed (as the simpliest method does). In addition it can display the inclination of the local facet. Averaging radius again determines the radius of the area to use for the plane fit. Button Set zero shifts the values to make the current z the new zero.

Inclinations

In all Gwyddion tools facet and plane inclinations are displayed as the spherical angles (ϑφ) of the plane normal vector.

Angle ϑ is the angle between the upward direction and the normal, this means ϑ = 0 for horizontal facets and increases with the slope. It is always positive.

Angle φ is the counter-clockwise measured angle between axis x and the projection of the normal to the xy plane, as displayed on the following figure. For facets it means φ corresponds to the downward direction of the facet.

Figure 4.2.  Surface facet (displayed blue) orientation measured as the counterclockwise angle from x-axis to the projection of facet normal vector n to xy plane.

Measuring facet orientation

Distance Tool

Distances and differences can be read with Distance tool. It displays the horizontal (Δx), vertical (Δy) and total planar (R) distances; the azimuth φ (measured identically to inclination φ) and the endpoint value difference (Δz) for a set of lines selected on the data.

The list of distances can be saved to a text file with Save button.

Figure 4.3.  Distance tool with three selected lines.

Distance tool dialog screenshot

Profile Extraction

Profile extraction tool can be accessed from the tools menu bar. You can use mouse to drag several profiles in the image that can be further moved and adjusted. Profile graph preview can be seen in the profile tool dialog. Profiles can be of different “thickness” which means that more neighbour data perpendicular to profile direction are used for evaluation of one profile point for thicker profiles. This can be very useful for noise suppression while measuring some regular objects.

After profiles are chosen, they can be extracted to graphs (separate of merged in one Graph window) that can be further analysed using Graph functions.

Figure 4.4.  Profile tool with three extracted profiles.

Profile tool dialog screenshot

References

[1] P. Thévenaz, T. Blu, M. Unser: Interpolation revisited. IEEE Transactions on medical imaging, Volume 10, Number 7, July 2000, 739