Module imagery.presentation.luminance_stretch

Percentile contrast stretch by relative luminance for decoded RGB8 images.

The image-domain operation uses color-d's sRGB and XYZ-D65 transfer definitions with float arithmetic. RGB8 decoding uses color-d's exact reusable byte table; color-d samples the encoded-sRGB output curve. The LDC vector path uses a dense direct-lookup table, while scalar paths interpolate. raster-d scoped data-plane windows execute the two pixel passes without per-sample accessor checks. Its 65,536-bin histogram is a uniform quantization of XYZ-D65 Y over [0,1]. An optional binary mask selects samples for estimating percentile bounds only; every pixel in the ROI receives the transform. The compile-time Clip argument chooses hard linear-sRGB clipping or fail-on-out-of-gamut behavior without a runtime policy branch.

Functions

NameDescription
tryRgbLuminanceStretchOwned(pixels, roi, lowerPercentile, upperPercentile, maxResultBytes, published, workerLimit, minimumChunk) Stretch an RGB8 ROI using percentile bounds from a 65,536-bin XYZ-D65-Y histogram. Encoded input bytes are interpreted as sRGB; alpha and metadata are not inferred. Y is measured after decoding to linear light. Each pixel is scaled uniformly in linear RGB, preserving chromaticity until optional hard clipping. Black pixels remain black because their chromaticity is undefined.
tryRgbLuminanceStretchOwned(pixels, roi, lowerPercentile, upperPercentile, selection, maxResultBytes, published, workerLimit, minimumChunk) Same operation with a binary mask used only to estimate percentile bounds. Mask bytes equal to zero are excluded from the histogram; any nonzero byte is included once. Every pixel in roi is transformed regardless of mask value.

Enums

NameDescription
LuminanceStretchError Result of RGB luminance percentile stretching.

Manifest constants

NameTypeDescription
luminanceStretchBinCount Fixed number of uniform bins covering relative XYZ-D65 Y in [0,1].