playnano.processing.mask_generators module

Module for masking features of AFM images in Numpy arrays.

playnano.processing.mask_generators.mask_adaptive(data: ndarray, block_size: int = 15, offset: float = 0.0) ndarray[source]

Adaptive local mean threshold per block.

Parameters:
  • data (numpy.ndarray) – Input 2D array.

  • block_size (int, optional) – Size of the local block. Default is 15.

  • offset (float, optional) – Value added to local mean when thresholding. Default is 0.0.

Returns:

Boolean mask array where True indicates pixels above the threshold.

Return type:

np.ndarray

playnano.processing.mask_generators.mask_below_threshold(data: ndarray, threshold: float = 0.0) ndarray[source]

Mask where data < threshold.

Parameters:
  • data (numpy.ndarray) – Input 2D array.

  • threshold (float, optional) – Threshold value. Pixels less than this will be True. Default is 0.0.

Returns:

Boolean mask array.

Return type:

np.ndarray

playnano.processing.mask_generators.mask_mean_offset(data: ndarray, factor: float = 1.0) ndarray[source]

Mask values greater than mean plus factor * standard deviation.

Parameters:
  • data (numpy.ndarray) – Input 2D array.

  • factor (float, optional) – Factor multiplied by the standard deviation to define the threshold. Default is 1.0.

Returns:

Boolean mask array.

Return type:

np.ndarray

playnano.processing.mask_generators.mask_morphological(data: ndarray, threshold: float = 0.0, structure_size: int = 3) ndarray[source]

Apply threshold and morphological closing to mask foreground.

Parameters:
  • data (numpy.ndarray) – Input 2D array.

  • threshold (float, optional) – Threshold value. Default is 0.0.

  • structure_size (int, optional) – Size of the structuring element for binary closing. Default is 3.

Returns:

Boolean mask array after morphological closing.

Return type:

np.ndarray

playnano.processing.mask_generators.mask_threshold(data: ndarray, threshold: float = 0.0) ndarray[source]

Mask where data > threshold.

Parameters:
  • data (numpy.ndarray) – Input 2D array.

  • threshold (float, optional) – Threshold value. Pixels greater than this will be True. Default is 0.0.

Returns:

Boolean mask array.

Return type:

np.ndarray

playnano.processing.mask_generators.register_masking()[source]

Return dictionary of available masking functions.

Returns:

Keys are function names (str), values are the corresponding callable functions.

Return type:

dict