AForge.NET

Testimonials
Features
Samples
Tools
Documentation
License
Downloads
Sources
Discussions
Partners
Projects
Members
Donate

AForge.NET Framework
2.2.5 version is available!

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
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 );
RGB levels linear correction

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 );
HSL levels linear correction

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 );
YCbCr levels linear correction

Brightness correction
The filter operates in RGB color space and adjusts pixels' brightness by increasing every pixel's RGB values by the specified value.

// create filter
BrightnessCorrection filter = new BrightnessCorrection( -50 );
// apply the filter
filter.ApplyInPlace( image );
Brightness correction

Contrast correction
The filter operates in RGB color space and adjusts pixels' contrast value by increasing RGB values of bright pixel and decreasing RGB values of dark pixels (or vise versa if contrast needs to be decreased).

// create filter
ContrastCorrection filter = new ContrastCorrection( 15 );
// apply the filter
filter.ApplyInPlace( image );
Contrast correction

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 );
Saturation correction