Skip to content

@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

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.