@mega-yfue/eufy-sdk / autoContrast
Function: autoContrast()
ts
function autoContrast(
data,
width,
height,
cutoff?
): void;Per-channel auto-contrast, a byte-exact port of PIL ImageOps.autocontrast (cutoff 0.5%). The lost quant tables leave the reconstruction low-contrast ("foggy"); stretching each channel's clipped range to full scale restores a natural-looking image. Mutates data (RGBA) in place.
Parity notes vs PIL: the cutoff count is n * cutoff // 100 (integer floor); it is trimmed off each end by zeroing whole histogram bins until the count is spent; the range is then the first/last non-empty bins; and the LUT truncates toward zero (int()), NOT rounds — rounding would shift pixels.
Parameters
data
Uint8Array
width
number
height
number
cutoff?
number = 0.5
Returns
void