phenotypic.abc_.DetectionMode#

class phenotypic.abc_.DetectionMode[source]#

Bases: ABC

Base class for detection matrix source modes.

Subclasses define how the detection matrix is computed from raw image data (grayscale, individual RGB channels, etc.).

Methods

__init__

compute

Return a fresh detection matrix from image.

compute_from_rgb

Project a substitute RGB array to a 2-D detection matrix.

Attributes

name

Short identifier used in detect_mode strings.

requires_rgb

Whether this mode needs RGB data to compute.

abstract property name: str#

Short identifier used in detect_mode strings.

abstract property requires_rgb: bool#

Whether this mode needs RGB data to compute.

abstractmethod compute(image: Image) np.ndarray[source]#

Return a fresh detection matrix from image.

Parameters:

image (Image) – The Image instance to compute from.

Returns:

A 2-D float32 array normalised to [0, 1].

Return type:

np.ndarray

abstractmethod compute_from_rgb(rgb: np.ndarray, *, image: Image) np.ndarray[source]#

Project a substitute RGB array to a 2-D detection matrix.

Unlike compute(), the pixel data comes from rgb rather than from image. image supplies colour configuration only (gamma, illuminant, _observer), which the CIE L*a*b* modes require and the others ignore.

Parameters:
  • rgb (np.ndarray) – Float RGB array normalized to [0, 1], shape (rows, cols, 3).

  • image (Image) – Source image, consulted for colour configuration only.

Returns:

A 2-D float32 array normalized to [0, 1].

Return type:

np.ndarray