This is an old revision of the document!
Contrast
Increasing the contrast increases the separation between dark and bright, making shadows darker and highlights brighter. Increasing it too much may clip both limits' values. Decreasing the contrast brings the shadows up and highlights down to make them closer to one another.
For our purposes we are going to adjust the pixel's L
component in the HSL color space, leaving the other two components intact as the Saturation shouldn't be affected by the Contrast and the Hue (at least for now) is also maintaining its invariance during this operation.
Assuming the L
component to be in range [0..100]
% the contrast adjustment looks like this:
// pseudo-code void contrast(/*array of pixels*/image, double _cst){ for(const & pixel: image){ pixel.luma = std::clamp((pixel.luma - 50) * _sct + 50, 0, 100); } }