tryRgbLuminanceStretchOwned - multiple declarations

Function tryRgbLuminanceStretchOwned

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.

LuminanceStretchError tryRgbLuminanceStretchOwned(bool Clip = true)(
  scope RasterView!ubyte pixels,
  Region2D roi,
  uint lowerPercentile,
  uint upperPercentile,
  size_t maxResultBytes,
  ref RasterLease!float published,
  size_t workerLimit = 0,
  size_t minimumChunk = 32
) @safe;

The histogram bins are uniform on [0,1], with bin floor(Y*65536) and 1.0 assigned to the final bin. Percentiles use nearest-rank selection. The bin width is 1/65536 in computed float Y; values close to a boundary follow float rounding. Bin bounds are used as threshold representatives. The optional binary mask affects threshold estimation only; all pixels in the ROI are transformed.

Clip=true clamps linear RGB to [0,1] before sRGB encoding. Clip=false returns outOfGamut and preserves the prior output if any transformed pixel leaves that range. The policy is selected at compile time with static if. Output is a new ROI-local interleaved RasterLease!float of normalized encoded-sRGB samples, published only on full success. The calculation uses float arithmetic. Output encoding linearly interpolates a compiler-tuned table (4,096 intervals for DMD and 1,024 for LDC) sampled through color-d. The byte budget limits only the new pixel payload.

Parameters

NameDescription
Clip Compile-time out-of-gamut policy; true clamps linear RGB, false rejects any result outside the sRGB gamut.
pixels Three-plane stored RGB8 image; byte values are encoded sRGB.
roi Nonempty in-bounds source region.
lowerPercentile Integer percentile from 0 through 99.
upperPercentile Integer percentile greater than lowerPercentile and at most 100.
maxResultBytes Maximum new float pixel payload.
published Output owner replaced only on success.
workerLimit Requested worker cap passed to raster-d's bounded row executor. Zero selects sequential execution.
minimumChunk Minimum logical rows per scheduled chunk; defaults to 32.

Returns

LuminanceStretchError.none on success.

Function tryRgbLuminanceStretchOwned

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.

LuminanceStretchError tryRgbLuminanceStretchOwned(bool Clip = true)(
  scope RasterView!ubyte pixels,
  Region2D roi,
  uint lowerPercentile,
  uint upperPercentile,
  scope RasterView!ubyte selection,
  size_t maxResultBytes,
  ref RasterLease!float published,
  size_t workerLimit = 0,
  size_t minimumChunk = 32
) @safe;

Parameters

NameDescription
Clip Compile-time out-of-gamut policy; true clamps linear RGB, false rejects any result outside the sRGB gamut.
pixels Three-plane stored RGB8 image; byte values are encoded sRGB.
roi Nonempty in-bounds source region.
lowerPercentile Integer percentile from 0 through 99.
upperPercentile Integer percentile greater than lowerPercentile and at most 100.
selection One-plane byte mask with the same dimensions as pixels.
maxResultBytes Maximum new float pixel payload.
published Output owner replaced only on success.
workerLimit Requested worker cap passed to raster-d's bounded row executor. Zero selects sequential execution.
minimumChunk Minimum logical rows per scheduled chunk; defaults to 32.

Returns

LuminanceStretchError.none on success.