phenotypic.abc_.DetectionMode#
- class phenotypic.abc_.DetectionMode[source]#
Bases:
ABCBase 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__Return a fresh detection matrix from image.
Project a substitute RGB array to a 2-D detection matrix.
Attributes
Short identifier used in
detect_modestrings.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
Imageinstance 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.imagesupplies 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