Image Processing - ChennaiSunday

By Beverly Allen,2014-06-17 08:28
8 views 0
Image Processing - ChennaiSunday ...

     Image Processing


    Image Processing Lab is a simple tool for image processing, which includes different filters and tools to analyze images available in AForge.NET framework. It's easy to develop your own filters and to integrate them with the code or to use the tools in your own application.

    The following filters are implemented in the AForge.NET framework and demonstrated in the application:

    ? Color filters (grayscale, sepia, invert, rotate, channel extraction, channel

    replacing, channel filtering, color filtering, Euclidean color filtering); ? HSL filters (linear correction, brightness, contrast, saturation, hue modifier,

    HSL filtering);

    ? YCbCr filters (linear correction, YCbCr filtering, channel


    ? Binarization filters (threshold, threshold with carry, ordered dithering, Bayer

    dithering, Floyd-Steinberg, Burkes, Jarvis-Judice-Ninke, Sierra, Stevenson-

    Arce, Stucki dithering methods);

    ? Automatic binarization (simple image statistics);

    ? Mathematical morphology filters (erosion, dilatation, opening, closing, hit &

    miss, thinning, thickening);

    ? Convolution filters (mean, blur, sharpen, edges, Gaussian); ? 2 Source filters (merge, intersect, add, subtract, difference, move towards,


    ? Edge detectors (homogeneity, difference, sobel, canny); ? Blob counter, Connected components labeling;

    ? Pixellate, Simple skeletonization, Jitter, Shrink, Oil painting; ? Levels linear filter, gamma correction;

    ? Median filter, Adaptive smoothing, Conservative smoothing; ? Resize and Rotate;

    ? Texture generators based on Perlin noise;

    ? Texture filters (texturer, textured filtering, textured merging); ? Fourier transformation (lowpass and hipass filters).

    You can create (save and load) your own convolution filters or filters based on standard mathematical morphology operators. Colorized grid makes it very convenient to work with custom convolution filters.

    A preview window allows you to view results of changing filter parameters on the fly. You can scroll an image using mouse in preview area. All filters are applied only to the portion of image currently viewed to speed up preview.

    A PhotoShop like histogram allows you to get information about mean, standard deviation, median, minimum and maximum values.

    The program allows to copy to or paste from clipboard, save and print images. Using the code

    Most filters are designed to work with 24bpp RGB images or with grayscale images. In the case of grayscale image, we use PixelFormat.Format8bppIndexed with color palette of 256 entries. To guarantee that your image is in one of the formats, you can use the following code:

    // load an image

    System.Drawing.Bitmap image = (Bitmap) Bitmap.FromFile( fileName ); // format image

    AForge.Imaging.Image.FormatImage( ref image );

    It is easy to apply any filter to your image:

    // load an image

System.Drawing.Bitmap image = (Bitmap) Bitmap.FromFile( fileName );

    // create filter

    AForge.Imaging.Filters.Median filter = new AForge.Imaging.Filters.Median( ); // apply filter

    System.Drawing.Bitmap newImage = filter.Apply( image );

    Suppose, you want to apply a series of filters to an image. The straight way to do it is to apply filters one after another, but it's not very likely in the case of 3 or more filters. All filters implement the IFilter interface, so it allows us to create a collection of filters and apply it at once to an image (besides, the collection will also save us from disposing routines on intermediate images):

    // create filters sequence AForge.Imaging.Filters.FiltersSequence

    filter = new AForge.Imaging.Filters.FiltersSequence( );

    // add filters to the sequence

    filter.Add( new AForge.Imaging.Filters.Sepia( ) );

    filter.Add( new AForge.Imaging.Filters.RotateBilinear( 45) );

    filter.Add( new AForge.Imaging.Filters.ResizeBilinear( 320, 240 ) );

    filter.Add( new AForge.Imaging.Filters.Pixellate( 8 ) );

    filter.Add( new AForge.Imaging.Filters.Jitter( 2 ) );

    filter.Add( new AForge.Imaging.Filters.Blur( ) );

    // apply the sequence to an image

    System.Drawing.Bitmap newImage = filter.Apply( image );

    It's easy to get such image statistics as mean, standard deviation, median, minimum and maximum values. It can be useful for image brightness/contrast regulation. // get image statistics

    AForge.Imaging.ImageStatistics statistics =

     new AForge.Imaging.ImageStatistics( image );

    // get the red histogram

    AForge.Math.Histogram histogram = statistics.Red;

    // get the values

    double mean = histogram.Mean; // mean red value

    double stddev = histogram.StdDev; // standard deviation of red values int median = histogram.Median; // median red value

    int min = histogram.Min; // min red value

    int max = histogram.Max; // max value

    // get 90% range around the median

    AForge.IntRange range = histogram.GetRange( 0.9 );

    Image statistics can be easily combined with filters. Suppose, the minimum value of red is 50 on the image and the maximum value is 200. So, we can normalize the contrast of the red channel:

    // create levels filter

    AForge.Imaging.Filters.LevelsLinear filter =

     new AForge.Imaging.Filters.LevelsLinear( );

    filter.InRed = new IntRange( histogram.Min, histogram.Max );

// apply the filter

    System.Drawing.Bitmap newImage = filter.Apply( image ); Or we can normalize the contrast of each channel, getting only the 90% ranges from

    each channel:

    // create levels filter

    AForge.Imaging.Filters.LevelsLinear filter =

     new AForge.Imaging.Filters.LevelsLinear( ); filter.InRed = statistics.Red.GetRange( 0.9 );

    filter.InGreen = statistics.Green.GetRange( 0.9 ); filter.InBlue = statistics.Blue.GetRange( 0.9 ); // apply the filter

    System.Drawing.Bitmap newImage = filter.Apply( image ); HSL Filters

    Using HSL color space is more obvious for some sort of filters. For example, it's not