phenotypic.measure.MeasureColor#
- class phenotypic.measure.MeasureColor(white_chroma_max: float = 4.0, chroma_min: float = 8.0, include_XYZ: bool = False)[source]
Bases:
MeasureFeaturesMeasure colony color statistics across multiple perceptual color spaces.
Extract per-colony color features from CIE XYZ, chromaticity (xy), CIE Lab (perceptually uniform), and HSV color spaces. For each channel the standard statistical suite is computed (min, Q1, mean, median, Q3, max, std dev, coefficient of variation), plus Lab chroma estimates.
- Args:
- white_chroma_max: Lab chroma threshold below which a colony is
classified as achromatic (white). Default:
4.0.- chroma_min: Minimum chroma value retained in analysis; colonies
below this are treated as colorless. Default:
8.0.- include_XYZ: Compute CIE XYZ tristimulus statistics (slower).
Default:
False.
- Returns:
pd.DataFrame: Object-level color statistics with column groups:
ColorXYZ (X, Y, Z) – only when
include_XYZ=True.Colorxy (x, y chromaticity).
ColorLab (L*, a*, b*, ChromaEstimated).
ColorHSV (Hue, Saturation, Brightness).
Each channel has Min, Q1, Mean, Median, Q3, Max, StdDev, CoeffVar sub-columns.
- Best For:
Distinguishing pigmented colonies (carotenoid, melanin) from colorless ones to stratify phenotypes by pigmentation profile.
Detecting sectoring and growth heterogeneity via high within-colony color variance.
Cross-plate comparison of colony pigmentation using perceptually uniform Lab distances.
- Consider Also:
MeasureIntensityfor grayscale-only brightness and variability statistics.MeasureColorCompositionfor proportion-based color classification of colony pixels.MeasureTexturefor surface-roughness features that complement color metrics.
- See Also:
Tutorial 7: Measuring and Exporting for a walkthrough of measuring and exporting colony data. Measurement Metrics and Their Biological Meaning for interpreting color metrics in a biological context.
Category: ColorXYZ# Name
Description
CieXMinThe minimum X value of the object in CIE XYZ color space
CieXQ1The lower quartile (Q1) X value of the object in CIE XYZ color space
CieXMeanThe mean X value of the object in CIE XYZ color space
CieXMedianThe median X value of the object in CIE XYZ color space
CieXQ3The upper quartile (Q3) X value of the object in CIE XYZ color space
CieXMaxThe maximum X value of the object in CIE XYZ color space
CieXStdDevThe standard deviation of the X value of the object in CIE XYZ color space
CieXCoeffVarThe coefficient of variation of the X value of the object in CIE XYZ color space
CieYMinThe minimum Y value of the object in CIE XYZ color space
CieYQ1The lower quartile (Q1) Y value of the object in CIE XYZ color space
CieYMeanThe mean Y value of the object in CIE XYZ color space
CieYMedianThe median Y value of the object in CIE XYZ color space
CieYQ3The upper quartile (Q3) Y value of the object in CIE XYZ color space
CieYMaxThe maximum Y value of the object in CIE XYZ color space
CieYStdDevThe standard deviation of the Y value of the object in CIE XYZ color space
CieYCoeffVarThe coefficient of variation of the Y value of the object in CIE XYZ color space
CieZMinThe minimum Z value of the object in CIE XYZ color space
CieZQ1The lower quartile (Q1) Z value of the object in CIE XYZ color space
CieZMeanThe mean Z value of the object in CIE XYZ color space
CieZMedianThe median Z value of the object in CIE XYZ color space
CieZQ3The upper quartile (Q3) Z value of the object in CIE XYZ color space
CieZMaxThe maximum Z value of the object in CIE XYZ color space
CieZStdDevThe standard deviation of the Z value of the object in CIE XYZ color space
CieZCoeffVarThe coefficient of variation of the Z value of the object in CIE XYZ color space
Category: Colorxy# Name
Description
xMinThe minimum chromaticity x coordinate of the object
xQ1The lower quartile (Q1) chromaticity x coordinate of the object
xMeanThe mean chromaticity x coordinate of the object
xMedianThe median chromaticity x coordinate of the object
xQ3The upper quartile (Q3) chromaticity x coordinate of the object
xMaxThe maximum chromaticity x coordinate of the object
xStdDevThe standard deviation of the chromaticity x coordinate of the object
xCoeffVarThe coefficient of variation of the chromaticity x coordinate of the object
yMinThe minimum chromaticity y coordinate of the object
yQ1The lower quartile (Q1) chromaticity y coordinate of the object
yMeanThe mean chromaticity y coordinate of the object
yMedianThe median chromaticity y coordinate of the object
yQ3The upper quartile (Q3) chromaticity y coordinate of the object
yMaxThe maximum chromaticity y coordinate of the object
yStdDevThe standard deviation of the chromaticity y coordinate of the object
yCoeffVarThe coefficient of variation of the chromaticity y coordinate of the object
Category: ColorLab# Name
Description
L*MinThe minimum L* value of the object
L*Q1The lower quartile (Q1) L* value of the object
L*MeanThe mean L* value of the object
L*MedianThe median L* value of the object
L*Q3The upper quartile (Q3) L* value of the object
L*MaxThe maximum L* value of the object
L*StdDevThe standard deviation of the L* value of the object
L*CoeffVarThe coefficient of variation of the L* value of the object
a*MinThe minimum a* value of the object
a*Q1The lower quartile (Q1) a* value of the object
a*MeanThe mean a* value of the object
a*MedianThe median a* value of the object
a*Q3The upper quartile (Q3) a* value of the object
a*MaxThe maximum a* value of the object
a*StdDevThe standard deviation of the a* value of the object
a*CoeffVarThe coefficient of variation of the a* value of the object
b*MinThe minimum b* value of the object
b*Q1The lower quartile (Q1) b* value of the object
b*MeanThe mean b* value of the object
b*MedianThe median b* value of the object
b*Q3The upper quartile (Q3) b* value of the object
b*MaxThe maximum b* value of the object
b*StdDevThe standard deviation of the b* value of the object
b*CoeffVarThe coefficient of variation of the b* value of the object
ChromaEstimatedMeanThe mean chroma estimation of the object calculated using \(\(sqrt(a^{*}_{mean}^2 + b^{*}_{mean})^2}\)
ChromaEstimatedMedianThe median chroma estimation of the object using \(\sqrt({a*_{median}^2 + b*_{median})^2}\)
Category: ColorHSV# Name
Description
HueMinThe minimum hue of the object
HueQ1The lower quartile (Q1) hue of the object
HueMeanThe mean hue of the object
HueMedianThe median hue of the object
HueQ3The upper quartile (Q3) hue of the object
HueMaxThe maximum hue of the object
HueStdDevThe standard deviation of the hue of the object
HueCoeffVarThe coefficient of variation of the hue of the object
SaturationMinThe minimum saturation of the object
SaturationQ1The lower quartile (Q1) saturation of the object
SaturationMeanThe mean saturation of the object
SaturationMedianThe median saturation of the object
SaturationQ3The upper quartile (Q3) saturation of the object
SaturationMaxThe maximum saturation of the object
SaturationStdDevThe standard deviation of the saturation of the object
SaturationCoeffVarThe coefficient of variation of the saturation of the object
BrightnessMinThe minimum brightness of the object
BrightnessQ1The lower quartile (Q1) brightness of the object
BrightnessMeanThe mean brightness of the object
BrightnessMedianThe median brightness of the object
BrightnessQ3The upper quartile (Q3) brightness of the object
BrightnessMaxThe maximum brightness of the object
BrightnessStdDevThe standard deviation of the brightness of the object
BrightnessCoeffVarThe coefficient of variation of the brightness of the object
Methods
__init__Execute the measurement operation on a detected-object image.
- __del__()
Automatically stop tracemalloc when the object is deleted.
- measure(image, include_meta=False)
Execute the measurement operation on a detected-object image.
This is the main public API method for extracting measurements. It handles: input validation, parameter extraction via introspection, calling the subclass-specific _operate() method, optional metadata merging, and exception handling.
How it works (for users):
Pass your processed Image (with detected objects) to measure()
The method calls your subclass’s _operate() implementation
Results are validated and returned as a pandas DataFrame
If include_meta=True, image metadata (filename, grid info) is merged in
How it works (for developers):
When you subclass MeasureFeatures, you only implement _operate(). This measure() method automatically:
Extracts __init__ parameters from your instance (introspection)
Passes matched parameters to _operate() as keyword arguments
Validates the Image has detected objects (objmap)
Wraps exceptions in OperationFailedError with context
Merges grid/object metadata if requested
- Parameters:
image (Image) – A PhenoTypic Image object with detected objects (must have non-empty objmap from a prior detection operation).
include_meta (bool, optional) – If True, merge image metadata columns (filename, grid position, etc.) into the results DataFrame. Defaults to False.
- Returns:
Measurement results with structure:
First column: OBJECT.LABEL (integer IDs from image.objmap[:])
Remaining columns: Measurement values (float, int, or string)
One row per detected object
If include_meta=True, additional metadata columns are prepended before OBJECT.LABEL (e.g., Filename, GridRow, GridCol).
- Return type:
pd.DataFrame
- Raises:
OperationFailedError – If _operate() raises any exception, it is caught and re-raised as OperationFailedError with details including the original exception type, message, image name, and operation class. This provides consistent error handling across all measurers.
Notes
This method is the main entry point; do not override in subclasses
Subclasses implement _operate() only, not this method
Automatic memory profiling is available via logging configuration
Image must have detected objects (image.objmap should be non-empty)
Examples
Basic measurement extraction:
>>> from phenotypic import Image >>> from phenotypic.measure import MeasureSize >>> from phenotypic.detect import OtsuDetector >>> # Load and detect >>> image = Image('plate.jpg') >>> image = OtsuDetector().operate(image) >>> # Extract measurements >>> measurer = MeasureSize() >>> df = measurer.measure(image) >>> print(df.head())
Include metadata in measurements:
>>> # With image metadata (filename, grid info) >>> df_with_meta = measurer.measure(image, include_meta=True) >>> print(df_with_meta.columns) # Output: ['Filename', 'GridRow', 'GridCol', 'OBJECT.LABEL', # 'Area', 'IntegratedIntensity', ...]