Expand description
Photoshop-style soft light blend, over 2-D (H, W) and 3-D (H, W, C) arrays.
Matches blend.py’s soft_light() exactly (verified in
tests/test_blend.py’s Rust-parity tests, when the extension is
built). Per element, with base a and blend b:
b <= 0.5: 2ab + a²(1 - 2b)
b > 0.5: 2a(1 - b) + sqrt(clamp(a, 0, 1)) · (2b - 1)and the result is clamped to [0, 1].
§Which function to call
Call soft_light_core (2-D) or soft_light_rgb_core (3-D). They
pick the serial or parallel path using
PARALLEL_THRESHOLD.
The *_serial/*_parallel variants are public only so
benches/blend_bench.rs can time both paths at every array size to
tune that threshold. Benches are separate crates and can only call
pub items.
Functions§
- soft_
light_ core - Soft light blend of two 2-D arrays. The entry point for 2-D inputs.
- soft_
light_ parallel - Soft light blend of two 2-D arrays, parallelised with rayon.
- soft_
light_ rgb_ core - Soft light blend of two 3-D (H, W, C) arrays, e.g. RGB or RGBA imagery, in a single pass. The entry point for multi-channel inputs.
- soft_
light_ rgb_ parallel - Soft light blend of two 3-D arrays, parallelised with rayon.
- soft_
light_ rgb_ serial - Soft light blend of two 3-D arrays, single-threaded.
- soft_
light_ serial - Soft light blend of two 2-D arrays, single-threaded.