Image Statistics
AForge.NET framework provides set of routines to calculate different type of statistics
information about image, like histogram, mean color values, standard deviation, median, etc. The
information may be very useful as in different type of image enhancement, as in many other image
processing tasks.
Image Statistics
The routine is used to accumulate statistical values about images, like histogram, mean, standard deviation,
etc. for each color channel in RGB color space.
// gather statistics
ImageStatistics stat = new ImageStatistics( image );
// get red channel's histogram
Histogram red = stat.Red;
// check mean value of red channel
if ( red.Mean > 128 )
{
// do further processing
}
Similar information may be obtained for HSL and YCbCr color spaces, using
Image Statistics HSL and
Image Statistics YCbCr routines.
Vertical Intensity Statistics
The routine provides information about vertical distribution of pixel intensities, which may be used to
locate objects, their centers, etc.
// collect statistics
VerticalIntensityStatistics vis = new VerticalIntensityStatistics( sourceImage );
// get gray histogram (for grayscale image)
Histogram histogram = vis.Gray;
// output some histogram's information
System.Diagnostics.Debug.WriteLine( "Mean = " + histogram.Mean );
System.Diagnostics.Debug.WriteLine( "Min = " + histogram.Min );
System.Diagnostics.Debug.WriteLine( "Max = " + histogram.Max );
Horizontal Intensity Statistics
The class provides information about horizontal distribution of pixel intensities, which may be used to
locate objects, their centers, etc.
// collect statistics
HorizontalIntensityStatistics his = new HorizontalIntensityStatistics( sourceImage );
// get gray histogram (for grayscale image)
Histogram histogram = his.Gray;
// output some histogram's information
System.Diagnostics.Debug.WriteLine( "Mean = " + histogram.Mean );
System.Diagnostics.Debug.WriteLine( "Min = " + histogram.Min );
System.Diagnostics.Debug.WriteLine( "Max = " + histogram.Max );
