Histogram equalization filter.

The filter does histogram equalization increasing local contrast in images. The effect of histogram equalization can be better seen on images, where pixel values have close contrast values. Through this adjustment, pixels intensities can be better distributed on the histogram. This allows for areas of lower local contrast to gain a higher contrast without affecting the global contrast.

The filter accepts 8 bpp grayscale images and 24/32 bpp color images for processing.

For color images the histogram equalization is applied to each color plane separately.

Sample usage:

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

Source image:

Result image:

Inheritance: BaseInPlacePartialFilter
Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            var image = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");
            var fp = new FingerprintTemplate(image);

            Bitmap img = (Bitmap) Bitmap.FromFile(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");

            HistogramEqualization equalization = new HistogramEqualization();
            equalization.ApplyInPlace(img);

            img.Save("Aforge.bmp");
        }
Exemplo n.º 2
0
 // =========================================================
 private void HistogramFunct(ref Bitmap frame, int par_int, double par_d, int par_R, int par_G, int par_B)
 {
     // create MirrFilter
     HistogramEqualization filter = new HistogramEqualization();
     // process image
     filter.ApplyInPlace(frame);
 }
Exemplo n.º 3
0
        public static Bitmap HistogramEquilization(Bitmap bmp)
        {
            // create filter
            HistogramEqualization filter = new HistogramEqualization();
            // process image
            filter.ApplyInPlace(bmp);
            return bmp;

        }
Exemplo n.º 4
0
        // Process image
        private void ProcessImage(Bitmap bitmap)
        {
            // create filter
            HistogramEqualization hisFilter = new HistogramEqualization();
            // process image
            //hisFilter.ApplyInPlace(Image);

            // create filter
            ContrastCorrection contrastFilter = new ContrastCorrection(4);
            // apply the filter
            contrastFilter.ApplyInPlace(bitmap);

            //QuantizeImage(bitmap);

            Grayscale grayscaleFilter = new Grayscale(0.33, 0.33, 0.34);
            // apply the filter
            Bitmap grayImage = grayscaleFilter.Apply(bitmap);

            // create filter
            SobelEdgeDetector sobelFilter = new SobelEdgeDetector();
            // apply the filter
            sobelFilter.ApplyInPlace(grayImage);
            Threshold filter = new Threshold(110);
            // apply the filter
            filter.ApplyInPlace(grayImage);

            if (GetIntersect(grayImage, bitmap, intersectPoint)) {
                //MessageBox.Show("draw");
                Graphics g = Graphics.FromImage(bitmap);
                //Sorting

                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        for (int k = 0; k < 19 - 1; k++)
                        {
                            if (Math.Abs(intersectPoint[1, i, k]) > Math.Abs(intersectPoint[1, i, k + 1]))
                            {
                                int tempX = Math.Abs(intersectPoint[0, i, k]);
                                int tempY = Math.Abs(intersectPoint[1, i, k]);
                                intersectPoint[0, i, k] = Math.Abs(intersectPoint[0, i, k + 1]);
                                intersectPoint[1, i, k] = Math.Abs(intersectPoint[1, i, k + 1]);
                                intersectPoint[0, i, k + 1] = tempX;
                                intersectPoint[1, i, k + 1] = tempY;
                                //MessageBox.Show(i + " " + k +" " +tempX + " " + tempY + " " + intersectPoint[0, i, k] + " " + intersectPoint[1, i, k] ,"ok", MessageBoxButtons.OK);
                            }
                        }
                    }
                }

                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        for (int k = 0; k < 19 - 1; k++)
                        {
                            if (Math.Abs(intersectPoint[0, k, i]) > Math.Abs(intersectPoint[0, k + 1, i]))
                            {
                                int tempX = Math.Abs(intersectPoint[0, k, i]);
                                int tempY = Math.Abs(intersectPoint[1, k, i]);
                                intersectPoint[0, k, i] = intersectPoint[0, k + 1, i];
                                intersectPoint[1, k, i] = intersectPoint[1, k + 1, i];
                                intersectPoint[0, k + 1, i] = tempX;
                                intersectPoint[1, k + 1, i] = tempY;
                            }
                        }
                    }
                }

                Pen redPen = new Pen(Color.Red, 4);
                for (int i = 0; i < 19; i++)
                {
                    for (int j = 0; j < 19; j++)
                    {
                        g.DrawEllipse(redPen, Math.Abs(intersectPoint[0, i, j]) , Math.Abs(intersectPoint[1, i, j]) , (int)5, (int)5);
                        //g.DrawEllipse(redPen, 0, 0, (int)5, (int)5);

                        //Debug.WriteLine((Math.Abs(intersectPoint[0, i, j]) - 2) + " " + (Math.Abs(intersectPoint[1, i, j]) - 2));
                    }
                }

                Pen greenPen = new Pen(Color.Green, 4);

                greenPen.Dispose();
                redPen.Dispose();
                g.Dispose();

                // Initializes the variables to pass to the MessageBox.Show method.
                EspacioCamera.Image = bitmap;
                string message = "Do you accecpt this detection?";
                string caption = "The system found totally 38 lines.";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result;

                // Displays the MessageBox.

                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    // Closes the parent form.
                    locked = true;
                }
            }

            EspacioCamera.Image = bitmap;
        }
Exemplo n.º 5
0
 public static void HistogramEqualization(this Bitmap image)
 {
     AForge.Imaging.Filters.HistogramEqualization filter = new AForge.Imaging.Filters.HistogramEqualization();
     filter.ApplyInPlace(image);
 }
Exemplo n.º 6
0
        private void eqHistogram_Click(object sender, RoutedEventArgs e)
        {
            ClearTextBoxes();

            brightness = 0;
            Brightness.Value = 0;

            if (eqHistogram.IsChecked == true)
            {
                HistogramEqualization filter = new HistogramEqualization();
                filter.ApplyInPlace(mainPhoto);
                Photography.Source = ToBitmapImage(mainPhoto);
            }
            else
            {
                UpdatePicture(ImageURL);
                Photography.Source = ToBitmapImage(mainPhoto);
            }

            mainPhotoIS = Photography.Source;
            UpdateHistograms(null);
            UpdateChannelPreviews(null);
        }
Exemplo n.º 7
0
 // =========================================================
 private void HistogramFunct(ref Bitmap frame)
 {
     // create filter
     HistogramEqualization filter = new HistogramEqualization();
     // process image
     filter.ApplyInPlace(frame);
 }