filters

Contains filter functions that take a 2D array representing an image as an input, as well as necessary parameters, and return a 2D array of the same size representing the filtered image.

topostats.filters.align_rows(image: numpy.array, mask: Optional[numpy.array] = None) numpy.array[source]

Returns the input image with rows aligned by median height

Parameters
  • image (np.array) – Numpy array representing image.

  • mask (np.array) – Mask array to apply.

Returns

Numpy array of image but with any linear plane slant removed.

Return type

np.array

topostats.filters.amplify(image: numpy.array, level: float) numpy.array[source]

The amplify filter mulitplies the value of all pixels by the level argument.

Parameters

image: np.array

Numpy array representing image.

level: np.array

Factor by which to amplify the array.

Returns

Numpy array of image amplified by level.

Return type

np.array

topostats.filters.average_background(image: numpy.array, mask: Optional[numpy.array] = None) numpy.array[source]

Zero the background based on the median.

Parameters
  • image (np.array) – Numpy array representing image.

  • mask (np.array) – Mask of the array, should have the same dimensions as image.

Returns

Numpy array of image zero averaged.

Return type

np.array

topostats.filters.calc_diff(array: numpy.array) numpy.array[source]

Calculate the difference of an array.

Parameters

image (np.array) – Numpy array representing image.

Return type

np.array

topostats.filters.calc_gradient(array: numpy.array, shape: int) numpy.array[source]

Calculate the gradient of an array.

Parameters
  • image (np.array) – Numpy array representing image.

  • shape (int) – Shape of the array in terms of the number of rows, typically it will be array[0].

Return type

np.array

topostats.filters.extract_channel(scan_raw: pySPM.Bruker, channel: str = 'Height') pySPM.SPM.SPM_image[source]

Extract the given channel from the image.

Parameters
  • scan_raw (pySPM.Bruker) – Raw scan loaded by pySPM.

  • channel (str) – Channel to extract (default is ‘Height’).

  • filename (str) – File being processed.

Returns

SPM image.

Return type

SPM_image

Examples

FIXME: Add docs.

topostats.filters.extract_img_name(img_path: Union[str, pathlib.Path]) str[source]

Extract the image name from the image path.

Parameters

img_path (Union[str, Path]) – Path to image being processed.

Returns

Filename of processed image.

Return type

str

Examples

FIXME: Add docs.

topostats.filters.extract_pixel_to_nm_scaling(extracted_channel: pySPM.SPM.SPM_image) float[source]

Extract the pixel to nanometer scaling from the image metadata.

Parameters

extracted_channel (SPM_image) – Channel extracted from an image.

Returns

Scaling factor for pixels to nanometers.

Return type

float

topostats.filters.extract_pixels(extracted_channel: pySPM.SPM.SPM_image) numpy.array[source]

Flatten the scan to a Numpy Array

Parameters

extracted_channel (SPM_image) – Channel extracted from an image.

Returns

Numpy array representation of the channel of interest.

Return type

np.array

Examples

FIXME: Add docs.

topostats.filters.remove_x_y_tilt(image: numpy.array, mask: Optional[numpy.array] = None) numpy.array[source]

Returns the input image after removing any linear plane slant

Parameters
  • image (np.array) – Numpy array representing image.

  • mask (np.array) – Mask array to apply.

Returns

Numpy array of image but with any linear plane slant removed.

Return type

np.array

topostats.filters.row_col_quantiles(image: numpy.array, mask: Optional[numpy.array] = None) numpy.array[source]

Returns the height value quantiles for the rows and columns.

Parameters
  • image (np.array) – Numpy array representing image.

  • mask (np.array) – Mask array to apply.

Returns

Numpy array of image but with any linear plane slant removed.

Return type

np.array