Linear color correction filters
AForge.NET framework provides number of filters, which perform linear correction of
pixels' values in different color spaces - RGB, HSL, YCbCr. Depending on chosen color space,
these filters may update different properties of image, like RGB balance, luminance, saturation, etc.
Source image
RGB levels linear correction
Performs linear correction of RGB channels by mapping specified channels' input ranges to output ranges.
// create filter
LevelsLinear filter = new LevelsLinear( );
// set ranges
filter.InRed = new IntRange( 30, 230 );
filter.InGreen = new IntRange( 50, 240 );
filter.InBlue = new IntRange( 10, 210 );
// apply the filter
filter.ApplyInPlace( Image );
HSL levels linear correction
The filter operates in HSL color space and provides with the facility of luminance and saturation linear correction - mapping specified channels' input
ranges to specified output ranges.
// create filter
HSLLinear filter = new HSLLinear( );
// configure the filter
filter.InLuminance = new DoubleRange( 0, 0.85 );
filter.OutSaturation = new DoubleRange( 0.25, 1 );
// apply the filter
filter.ApplyInPlace( image );
YCbCr levels linear correction
The filter operates in YCbCr color space and provides with the facility of linear correction of its channels - mapping specified channels' input
ranges to specified output ranges.
// create filter
YCbCrLinear filter = new YCbCrLinear( );
// configure the filter
filter.InCb = new DoubleRange( -0.276, 0.163 );
filter.InCr = new DoubleRange( -0.202, 0.500 );
// apply the filter
filter.ApplyInPlace( image );
Brightness correction
The filter operates in HSL color space and adjusts pixels' brightness value using luminance value of HSL color space,
increasing it or decreasing by specified percentage.
// create filter
SaturationCorrection filter = new SaturationCorrection( -0.15 );
// apply the filter
filter.ApplyInPlace( image );
Contrast correction
The filter operates in HSL color space and adjusts pixels contrast value using luminance value of HSL color space,
increasing it or decreasing by specified factor.
// create filter
ContrastCorrection filter = new ContrastCorrection( 2.0 );
// apply the filter
filter.ApplyInPlace( image );
Saturation correction
The filter operates in HSL color space and adjusts pixels' saturation value, increasing it or decreasing by specified percentage.
// create filter
SaturationCorrection filter = new SaturationCorrection( -0.5 );
// apply the filter
filter.ApplyInPlace( image );
|