phenotypic.util.medoid_ciede2000#
- phenotypic.util.medoid_ciede2000(lab_points: numpy.ndarray, max_pixels: int = 1000, seed: int = 0, chunk_size: int = 128) tuple[TypeAliasForwardRef('numpy.ndarray'), TypeAliasForwardRef('numpy.ndarray')][source]#
ΔE2000 medoid center and per-pixel ΔE2000 distances to it.
The medoid (real pixel minimizing total ΔE2000) is selected from a seeded subsample of at most
max_pixels; the returned distances are computed from the chosen medoid to all input pixels.The total-distance (“row sum”) used to pick the medoid is accumulated in candidate blocks of
chunk_sizerows rather than materializing the fullm x mpairwise matrix. Peak memory is thereforeO(chunk_size * m)instead ofO(m^2)(CIEDE2000 allocates many intermediate arrays the size of its broadcast grid). The result is bit-identical to the full-matrix form for anychunk_size– chunking bounds memory, not accuracy.- Parameters:
lab_points (numpy.ndarray) – (N, 3) CIE L*a*b* pixel vectors.
max_pixels (int) – Subsample cap for medoid selection.
seed (int) – RNG seed for reproducible subsampling.
chunk_size (int) – Number of candidate rows scored per block; caps peak memory.
- Returns:
(center (3,), all_deltas (N,)). center is all-NaN and all_deltas empty when
lab_pointsis empty.- Return type:
tuple[TypeAliasForwardRef(‘numpy.ndarray’), TypeAliasForwardRef(‘numpy.ndarray’)]