playnano.processing.filters module

Module for applying flattening and filtering to AFM images in Numpy arrays.

playnano.processing.filters.gaussian_filter(data: ndarray, sigma: float = 1.0) ndarray[source]

Apply a Gaussian low-pass filter to smooth high-frequency noise.

Parameters:
  • data (np.ndarray) – 2D AFM image data.

  • sigma (float) – Standard deviation for Gaussian kernel, in pixels.

Returns:

Smoothed image.

Return type:

np.ndarray

playnano.processing.filters.polynomial_flatten(data: ndarray, order: int = 2) ndarray[source]

Subtract a 2D polynomial surface of given order to flatten AFM image data.

Parameters:
  • data (np.ndarray) – 2D AFM image data.

  • order (int) – Polynomial order for surface fitting (e.g., 1 for linear, 2 for quadratic).

Returns:

Flattened image with polynomial background removed.

Return type:

np.ndarray

Raises:

ValueError – If data is not a 2D array or if order is not a positive integer.

playnano.processing.filters.register_filters()[source]

Return list of filter options.

playnano.processing.filters.remove_plane(data: ndarray) ndarray[source]

Fit a 2D plane to the image using linear regression and subtract it.

Uses a 2D plane (z = ax + by + c) to remove to remove overall tilt.

Parameters:

data (np.ndarray) – 2D AFM image data.

Returns:

Plane-removed image.

Return type:

np.ndarray

playnano.processing.filters.row_median_align(data: ndarray) ndarray[source]

Subtract the median of each row from that row to remove horizontal banding.

Parameters:

data (np.ndarray) – 2D AFM image data.

Returns:

Row-aligned image.

Return type:

np.ndarray

playnano.processing.filters.zero_mean(data: ndarray, mask: ndarray = None) ndarray[source]

Subtract the overall mean height to center the background around zero.

If a mask is provided, mean is computed only over background (mask == False).

Parameters:
  • data (np.ndarray) – 2D AFM image data.

  • mask (np.ndarray, optional) – Boolean mask of same shape as data; True indicates region to exclude from mean.

Returns:

Zero-mean image.

Return type:

np.ndarray