playnano.processing.masked_filters module¶
Module for filtering AFM data in NumPy arrays with a boolean mask.
- playnano.processing.masked_filters.polynomial_flatten_masked(data: ndarray, mask: ndarray, order: int = 2) ndarray[source]¶
Fit a 2D polynomial using background (mask==False) and subtract it.
- Parameters:
data (np.ndarray) – 2D AFM image.
order (int) – Polynomial order. Default order=2.
mask (np.ndarray) – Boolean mask of same shape; True=foreground, False=background.
- Returns:
Polynomial-flattened image.
- Return type:
np.ndarray
- Raises:
ValueError – If mask.shape != data.shape or order is not a positive integer.
- playnano.processing.masked_filters.remove_plane_masked(data: ndarray, mask: ndarray) ndarray[source]¶
Fit a 2D plane on background only and subtract it from the full image.
- Parameters:
data (np.ndarray) – 2D AFM image.
mask (np.ndarray) – Boolean mask of same shape; True=foreground (excluded), False=background (used to fit).
- Returns:
Plane-removed image.
- Return type:
np.ndarray
- Raises:
ValueError – If mask.shape != data.shape.
- playnano.processing.masked_filters.row_median_align_masked(data: ndarray, mask: ndarray) ndarray[source]¶
Compute each row’s median using background pixels and subtract from each full row.
- Parameters:
data (np.ndarray) – 2D AFM image.
mask (np.ndarray) – Boolean mask of same shape; True=foreground, False=background.
- Returns:
Row-masked-alignment image.
- Return type:
np.ndarray
- Raises:
ValueError – If mask.shape != data.shape.
- playnano.processing.masked_filters.zero_mean_masked(data: ndarray, mask: ndarray) ndarray[source]¶
Subtract the mean of background pixels (mask==False) from the entire image.
- Parameters:
data (np.ndarray) – 2D AFM image.
mask (np.ndarray) – Boolean mask of same shape; True=foreground, False=background.
- Returns:
Image with zero-mean background.
- Return type:
np.ndarray