CodeCarvings Piczard V1.2 Help
Adjust And Change Image Colors
Send Feedback
Piczard Fundamentals - Core > Built-in Filters > Adjust And Change Image Colors

Glossary Item Box


  1. Image adjustments filter
  2. Default color filters
  3. ColorMatrix filter 
  4. Multiple color filters



Please see the Example A.222 - "Adjust and change image colors".

The 3 builtin classes that allow to manipulate image colors are available through the CodeCarvings.Piczard.Filters.Colors Namespace.



1. Image adjustments filter 

The ImageAdjustmentsFilter class allows to change Brightness, Contrast, Hue and/or Saturation of an image.


Copy Code
// Example 1 - Adjust Brightness & Contrast
new ImageAdjustmentsFilter(-20, 30).SaveProcessedImageToFileSystem("Source1.jpg", "Output1.jpg");

// Example 2 - Adjust Contrast & Saturation
ImageAdjustmentsFilter filter2 = new ImageAdjustmentsFilter();
filter2.Contrast = 20F;
filter2.Saturation = -50F;
"Source2.jpg", "Output2.jpg");


Figure 1: Image Adjustment Filter demos.



2. Default color filters

Piczard provides 3 built-in common color filters accessible as static properties through the DefaultColorFilters class.


Copy Code
DefaultColorFilters.Grayscale.SaveProcessedImageToFileSystem("Source.jpg", "Output.jpg");

The filters are the following:

  1. DefaultColorFilters.Grayscale

    Figure 2: Grayscale color filter.

  2. DefaultColorFilters.Sepia

    Figure 3: Grayscale color filter.

  3. DefaultColorFilters.Invert

    Figure 4: Invert color filter. 



3. Color matrix filter

ColorMatrixFilter is the main base class that allows to manipulate image colors in Piczard.
It allows to apply one or more System.Drawing.Imaging.ColorMatrix objects to an image.
Each color matrix is applied in chain - one after the other - to the image.

For more information about Color Matrices in GDI+ please see:


Copy Code
// Prepare one ColorMatrix to apply
System.Drawing.Imaging.ColorMatrix cm1 = new ColorMatrix();
[4, 0] = 0.9F;

// Apply the ColorMatrix object (it is also possible pass an array of ColorMatrix objects)
CodeCarvings.Piczard.Filters.Colors.ColorMatrixFilter cmFilter = new ColorMatrixFilter(cm1);
"Source.jpg", "Output.jpg");

Figure 5: A ColorMatrixFilter applied to an image.



4. Multiple color filters

It is also possible to combine multiple color filters.
This makes extremely easy to get a huge number of combinations.

Copy Code
ImageProcessingJob job = new ImageProcessingJob();

// Sepia
job.Filters.Add(new ImageAdjustmentsFilter(0, 0, 100F, 0));      // Hue + 100

job.SaveProcessedImageToFileSystem("Source.jpg", "Output.jpg");


Figure 6: Sepia Color Filter + Image Adjustment Color Filter (hue + 100).


©2013 Sergio Turolla. All Rights Reserved.