Basic Operations

Value-reading and basic geometrical operations represent the core of any data processing program. Gwyddion offers a wide set of functions for data scaling, rotation, resampling or profile extraction. This section describes these simple but essential functions.

Basic 2D Data Operations

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

  • Resample the data to chosen dimensions or scale using selected interpolation method by Data ProcessBasic OperationsScale
  • Crop the data using the Crop tool either in place or putting the result to a new image (with option Create new image). 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).
  • Extend the data with Data ProcessBasic OperationsExtend. Extending is essentially the opposite of cropping. Of course, adding more real data around the image borders is only possible by measuring more data. So this function offers, instead, several simple artificial extension methods such as mirrored and unmirrored periodic continuation or repetition of boundary values.
  • Rotate data by 90 degrees or by user-specified amount using some of the rotate functions: Data ProcessBasic OperationsRotate Clockwise, Rotate Anticlockwise or Rotate.
  • Flip the data horizontally (i.e. about the vertical axis) and vertically (i.e. about the horizontal axis) with Data ProcessBasic OperationsFlip Horizontally and Flip Vertically, respectively.
  • Flip the data about the centre (i.e. about both axes) with Data ProcessBasic OperationsFlip Both.
  • Invert the data values using the Invert Value function: Data ProcessBasic OperationsInvert Value. The values are inverted about the mean value which keeps the mean value unchanged.
  • Limit the data range by cutting values outside a specified range by Data ProcessBasic OperationsLimit Range. The range can be set numerically or taken from the false color map range previously set using the Color range tool and it is also possible to cut off outliers farther than a chosen multiple of RMS from the mean value.
  • Upsample the 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.
  • Tilt the data by specified gradient or angle using Data ProcessBasic OperationsTilt.
  • Change physical dimensions, units or value scales and also lateral offsets using Data ProcessBasic operationsDimensions and Units. This is useful to correct raw data that have been imported with wrong physical scales or as a simple manual recalibration of dimensions and values.

Reading Values

The simplest value reading method 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 data window or graph window status bar.

Read Value Tool

Tool Read Value offers more value reading possibilities: it displays coordinates and values of the last point of the data window the mouse button was pressed. It can average 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 simplest method does). Button Set Zero shifts the surface to make the current z the new zero level.

Read Value can also display the inclination of the local facet. Averaging radius again determines the radius of the area to use for the plane fit.


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 that ϑ = 0 for horizontal facets and it 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.

Measuring facet orientation

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

Distance Tool

Distances and differences can be measured with the 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 distances can be copied to the clipboard or saved to a text file using the buttons below the list.

Distance tool dialog screenshot

Distance tool with three selected lines.

Profile Extraction

The profile extraction tool can be accessed from the toolbox. You can use mouse to draw several profiles in the image and they can be further moved and adjusted. The dialog includes a live profile graph preview. 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 regular objects.

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

Profile tool dialog screenshot

Profile tool with three extracted profiles and expanded options.

The profile curve is constructed from data sampled at regular intervals along the selected line. Values in points that do not lie exactly at pixel centres (which normally occurs for oblique lines) are interpolated using the chosen interpolation mode. Unless an explicit number of samples to take is set using the Fix res. option, the number of samples corresponds to the line length in pixels. This means that for purely horizontal or purely vertical lines no interpolation occurs.

Profile subpixel interpolation scheme

Illustration of data sampling in profile extraction for oblique lines. The figures on the left show the points along the line where the values are read for natural and very high resolution. The graphs on the right show the extracted values. Comparison of the natural and high resolution profiles taken with Round interpolation reveals that indeed natural-resolution curve points form a subset of the high-resolution points. The influence of the interpolation method on values taken in non-grid positions is demonstrated by the lower two graphs, comparing Round and Key interpolation at high resolution.

Radial profiles

It is also possible to extract radial profiles, i.e. angularly averaged shapes of symmetrical surface features, by selecting the Radial profiles check box. In this case the abscissa of the extracted graph is the distance from the centre instead of the distance along the line. The origin is in the centre of the selected line.

Although the line can be adjusted manually, finding the best centre for the radial profile manually may be difficult. Therefore, the tool can perform the precise location of the best centre itself. You only need to select the line approximately and then press Symmetrize to adjust the currently edited line or Symmetrize All to adjust all lines. The lines will be shifted slightly to minimise the differences between line profiles taken in different directions from the centre.

Conversion to other data types

Function Data ProcessBasic OperationsVolumize creates volume data from an image. The height field is interpreted as the surface of a solid object, as usual in AFM. Voxels below the surface (inside the material) are filled with 1s while voxels above the surface (outside) are filled with 0s. The z-coordinate of the volume data therefore corresponds to the image values, while the volume data values are unitless.

Function Data ProcessBasic OperationsVolumize Layers creates volume data from a sequence of images. All images in the file must have the same dimensions. They are then treated as planes in the volume data that are created by stacking the images. The z-coordinate of the volume data therefore corresponds to the stack index (and can be specified in the dialogue), while the volume data values have the same units as the image data.

Function Data ProcessBasic OperationsXYZize creates XYZ data from an image. Each image pixel corresponds to one point in the created XYZ data. Therefore, the xy coordinates thus form a regular grid and all units are the same as for the image.