Search code examples
c#imageaforgeadjustmentaccord.net

Do something similar to Auto Tone of Photoshop with Aforge.net or c#


Im developing an image skin detection app.

But there is a problem with my camera, that try to compensate the light and the result image is bad, in most of cases i have a cold or warm effect on the image. When i use photoshop there is the AutoTone function that normalize an image and reduce this problem.

Image

Image after Photoshop AutoTone

With aforge i want to use HistogramEqualization() filter but the result is very bad:

Image after HistogramEqualization

// create filter
HistogramEqualization filter = new HistogramEqualization( );
// process image
filter.ApplyInPlace( sourceImage );

So my question is: There is a function in Accord or Aforge to have the same result of the autotone of Photoshop? If not, there is some library or script that let to do this?

Thank you all.


Solution

  • I use the LevelsLinear filter and base it on image stats:

    ImageStatistics stats = new ImageStatistics(sourceImage);
    LevelsLinear levelsLinear = new LevelsLinear {
        InRed = stats.Red.GetRange( 0.90 ),
        InGreen = stats.Green.GetRange( 0.90 ),
        InBlue  = stats.Blue.GetRange( 0.90 )
    };
    
    levelsLinear.ApplyInPlace(sourceImage);
    

    You can play with the range to tweak the result.