//Relies less on neighbor pixels and more on RANSAC
    protected void fastHarrisRansacBlend(List <Bitmap> imgs)
    {
        List <IntPoint[]> harrisPoints = new List <IntPoint[]>();
        MatrixH           homography;

        //Calculate all the Harris Points
        HarrisCornersDetector harris = new HarrisCornersDetector(0.03f, 10000f);

        for (int i = 0; i < imgs.Count; i++)
        {
            harrisPoints.Add(harris.ProcessImage(imgs[i]).ToArray());
        }

        Bitmap final = imgs[0];

        for (int i = 1; i < imgs.Count; i++)
        {
            IntPoint[] harrisFinal = harris.ProcessImage(final).ToArray();

            //Correlate the Harris pts between imgs
            CorrelationMatching matcher = new CorrelationMatching(5, final, imgs[i]);
            IntPoint[][]        matches = matcher.Match(harrisFinal, harrisPoints[i]);

            //Create the homography matrix using ransac
            RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.025, 0.99);
            homography = ransac.Estimate(matches[0], matches[1]);

            Blend blend = new Blend(homography, final);
            blend.Gradient = true;
            final          = blend.Apply(imgs[i]);
        }

        showImage(final);
    }
示例#2
0
        /*
         * Detects feature points using Harris Corners Detection.
         * Corners are a good feature to match on photos because they are stable and have
         * large variations in their neighborhood.
         */

        private void HarrisCornersDetectorRecursive()
        {
            HarrisCornersDetector harris = new HarrisCornersDetector(0.04f, 1000f);

            harrisPoints1 = harris.ProcessImage(images[0]).ToArray();
            harrisPoints2 = harris.ProcessImage(images[1]).ToArray();
        }
示例#3
0
        public void ProcessImageTest()
        {
            UnmanagedImage image = UnmanagedImage.FromManagedImage(Accord.Imaging.Image.Clone(Properties.Resources.image1));

            HarrisCornersDetector target = new HarrisCornersDetector(0.04f, 1000f, 1.4);

            target.Suppression = 1;

            List <IntPoint> actual = target.ProcessImage(image);

            /*
             *             PointsMarker marker = new PointsMarker(actual.ToArray());
             *             marker.Width = 1;
             *             marker.MarkerColor = Color.FromArgb(128, 128, 128);
             *             var markers = marker.Apply(image);
             *             ImageBox.Show(markers.ToManagedImage(), PictureBoxSizeMode.Zoom);
             */

            /*
             *          Assert.AreEqual(4, actual.Count);
             *          Assert.IsTrue(actual.Contains(new IntPoint(3, 3)));
             *          Assert.IsTrue(actual.Contains(new IntPoint(14, 3)));
             *          Assert.IsTrue(actual.Contains(new IntPoint(3, 14)));
             *          Assert.IsTrue(actual.Contains(new IntPoint(14, 14)));
             */

            Assert.AreEqual(4, actual.Count);
            Assert.IsTrue(actual.Contains(new IntPoint(3, 3)));
            Assert.IsTrue(actual.Contains(new IntPoint(12, 3)));
            Assert.IsTrue(actual.Contains(new IntPoint(3, 12)));
            Assert.IsTrue(actual.Contains(new IntPoint(12, 12)));
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Open a image
            Bitmap lenna = Properties.Resources.lena512;

            double sigma     = (double)numSigma.Value;
            float  k         = (float)numK.Value;
            float  threshold = (float)numThreshold.Value;

            // Create a new Harris Corners Detector using the given parameters
            HarrisCornersDetector harris = new HarrisCornersDetector(k)
            {
                Measure = checkBox1.Checked ?
                          HarrisCornerMeasure.Harris : HarrisCornerMeasure.Noble,

                Threshold = threshold,
                Sigma     = sigma
            };

            // Create a new AForge's Corner Marker Filter
            CornersMarker corners = new CornersMarker(harris, Color.White);

            // Apply the filter and display it on a picturebox
            pictureBox1.Image = corners.Apply(lenna);
        }
        /// <summary>
        /// Harris Corners Detector.
        /// <para>Accord.NET internal call. Please see: <see cref="Accord.Imaging.HarrisCornersDetector"/> for details.</para>
        /// </summary>
        /// <typeparam name="TDepth">Channel type.</typeparam>
        /// <param name="im">Image.</param>
        /// <param name="measure">Corners measures.</param>
        /// <param name="threshold">Harris threshold.</param>
        /// <param name="sigma">Gaussian smoothing sigma.</param>
        /// <param name="suppression">Non-maximum suppression window radius.</param>
        /// <returns>Interest point locations.</returns>
        public static List <IntPoint> HarrisCorners <TDepth>(this Image <Gray, TDepth> im, HarrisCornerMeasure measure = HarrisCornerMeasure.Harris, float threshold = 20000f, double sigma = 1.2, int suppression = 3)
            where TDepth : struct
        {
            HarrisCornersDetector harris = new HarrisCornersDetector(measure, threshold, sigma, suppression);
            var points = harris.ProcessImage(im.ToAForgeImage(copyAlways: false, failIfCannotCast: true));

            return(points);
        }
        /// <summary>
        ///  Поиск ключевых точек
        /// </summary>
        /// <param name="sigma">Сигма</param>
        /// <param name="k">k</param>
        /// <param name="threshold">Граница</param>
        /// <param name="img">Изображение</param>
        /// <returns>Лист ключевых точек</returns>
        public List <IntPoint> KeyPoint(double sigma, float k, float threshold, Bitmap img)
        {
            HarrisCornersDetector harris = new HarrisCornersDetector(k)
            {
                Threshold = threshold,
                Sigma     = sigma
            };
            var OriginCorner = harris.ProcessImage(img);

            return(OriginCorner);
        }
    protected void fastHarrisRansacBlendStraight(List <Bitmap> imgs)
    {
        List <IntPoint[]> harrisPoints = new List <IntPoint[]>();
        MatrixH           homography;

        //Calculate all the Harris Points
        HarrisCornersDetector harris = new HarrisCornersDetector(0.03f, 10000f);

        for (int i = 0; i < imgs.Count; i++)
        {
            harrisPoints.Add(harris.ProcessImage(imgs[i]).ToArray());
        }

        Bitmap final = imgs[0];

        for (int i = 1; i < imgs.Count; i++)
        {
            //Convert my frames to grayscale so I can find and adjust the normal vectors
            AForge.Imaging.Filters.GrayscaleBT709 grayscale = new AForge.Imaging.Filters.GrayscaleBT709();
            AForge.Imaging.DocumentSkewChecker    skew      = new AForge.Imaging.DocumentSkewChecker();

            double finalAngle = skew.GetSkewAngle(grayscale.Apply(final));
            double imgAngle   = skew.GetSkewAngle(grayscale.Apply(imgs[i]));

            //Less than 5% to account for human error with rotations and wobbles
            if (Math.Abs(finalAngle - imgAngle) < 5)
            {
                AForge.Imaging.Filters.RotateBilinear rotate = new AForge.Imaging.Filters.RotateBilinear(finalAngle - imgAngle);
                rotate.FillColor = Color.FromArgb(0, 255, 255, 255);
                imgs[i]          = rotate.Apply(imgs[i]);

                //Update harris
                harrisPoints[i] = harris.ProcessImage(imgs[i]).ToArray();
            }

            IntPoint[] harrisFinal = harris.ProcessImage(final).ToArray();

            //Correlate the Harris pts between imgs
            CorrelationMatching matcher = new CorrelationMatching(5, final, imgs[i]);
            IntPoint[][]        matches = matcher.Match(harrisFinal, harrisPoints[i]);

            //Create the homography matrix using ransac
            RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.025, 0.99);
            homography = ransac.Estimate(matches[0], matches[1]);

            Blend blend = new Blend(homography, final);
            blend.Gradient = true;
            final          = blend.Apply(imgs[i]);
        }

        showImage(final);
    }
示例#8
0
        /// <summary>
        /// Harris Corners Detector.
        /// <para>Accord.NET internal call. Please see: <see cref="Accord.Imaging.HarrisCornersDetector"/> for details.</para>
        /// </summary>
        /// <param name="im">Image.</param>
        /// <param name="measure">Corners measures.</param>
        /// <param name="threshold">Harris threshold.</param>
        /// <param name="sigma">Gaussian smoothing sigma.</param>
        /// <param name="suppression">Non-maximum suppression window radius.</param>
        /// <returns>Interest point locations.</returns>
        public static List <IntPoint> HarrisCorners <TDepth>(this Gray <byte>[,] im, HarrisCornerMeasure measure = HarrisCornerMeasure.Harris, float threshold = 20000f, double sigma = 1.2, int suppression = 3)
        {
            HarrisCornersDetector harris = new HarrisCornersDetector(measure, threshold, sigma, suppression);

            List <IntPoint> points;

            using (var uImg = im.Lock())
            {
                points = harris.ProcessImage(uImg.AsAForgeImage());
            }

            return(points);
        }
示例#9
0
        public void GetCorners(int threshold, int sigma)
        {
            // create corners detector's instance
            HarrisCornersDetector hcd = new HarrisCornersDetector(HarrisCornerMeasure.Noble, threshold, sigma);

            // Apply the filter and return the points
            List <IntPoint> corners = hcd.ProcessImage(AForge.Imaging.Image.FromFile(this.CurrentImage));

            if (ImageComplete != null)
            {
                ImageComplete(corners);
            }
        }
        /// <summary>
        /// Поиск клювых точек и получение изображения с маркерами
        /// </summary>
        /// <param name="sigma">Сигма</param>
        /// <param name="k">k</param>
        /// <param name="threshold">Граница</param>
        /// <param name="img">Изображение</param>
        /// <param name="Height">Высота</param>
        /// <param name="Width">Ширина</param>
        /// <returns>Изображение с маркерами</returns>
        public Bitmap KeyPoint(double sigma, float k, float threshold, Bitmap img, int Height, int Width)
        {
            HarrisCornersDetector harris = new HarrisCornersDetector(k)
            {
                Threshold = threshold,
                Sigma     = sigma
            };
            CornersMarker corners    = new CornersMarker(harris, Color.DeepSkyBlue);
            var           CornerRrev = corners.Apply(img);
            var           DemoSize   = ResizeImg(Height, Width);
            var           DemoImg    = new Bitmap(CornerRrev, DemoSize.Item2, DemoSize.Item1);

            return(DemoImg);
        }
示例#11
0
        private void MakeCorners_Click(object sender, EventArgs e)
        {
            CornerListView.Items.Clear();

            // Zaciągnięcie pliku do bitmapy
            Bitmap image = Accord.Imaging.Image.FromFile("Samples/" + ImageList.Text);


            float kinput         = float.Parse(k_Input.Text);
            float thresholdinput = float.Parse(Threshold_input.Text);
            float sigmainput     = float.Parse(sigma_Input.Text);


            // Rozpoznawanie wierzchołków Harrisa (Lepiej się sprawdziło niż np. Suzan)
            HarrisCornersDetector target = new HarrisCornersDetector(kinput, thresholdinput, sigmainput);

            target.Suppression = 1;

            // Wyznaczenie wierzchołków do listy punktów
            List <Accord.IntPoint> actual = target.ProcessImage(image);

            for (int i = 0, n = actual.Count; i < n; i++)
            {
                // Listowanie punktów wierzchołków
                Console.WriteLine("Punkt: [" + actual[i].X + " , " + actual[i].Y + "]");

                CornerListView.Items.Add("Punkt " + (i + 1) + " : [" + actual[i].X + " , " + actual[i].Y + "]");

                try
                {
                    // Generowanie białych kwadratów w miejscu wierzchołków
                    for (int w = 0; w <= 10; w++)
                    {
                        for (int h = 0; h <= 10; h++)
                        {
                            image.SetPixel(actual[i].X + (w - 5), actual[i].Y + (h - 5), Color.White);
                        }
                    }
                }
                catch
                {
                    Console.WriteLine("Piksel za burtą!");
                }
            }



            Preview_1.Image = image;
        }
示例#12
0
        private void btnHarris_Click(object sender, EventArgs e)
        {
            // Step 1: Detect feature points using Harris Corners Detector
            HarrisCornersDetector harris = new HarrisCornersDetector(0.04f, 1000f);

            harrisPoints1 = harris.ProcessImage(img1).ToArray();
            harrisPoints2 = harris.ProcessImage(img2).ToArray();

            // Show the marked points in the original images
            Bitmap img1mark = new PointsMarker(harrisPoints1).Apply(img1);
            Bitmap img2mark = new PointsMarker(harrisPoints2).Apply(img2);

            // Concatenate the two images together in a single image (just to show on screen)
            Concatenate concatenate = new Concatenate(img1mark);

            pictureBox.Image = concatenate.Apply(img2mark);
        }
示例#13
0
        // Interest point detection
        private void InterestPtDetector()
        {
            // Step 1: Detect feature points using Harris Corners Detector
            HarrisCornersDetector harris = new HarrisCornersDetector(0.04f, 1000f);

            harrisPoints1 = harris.ProcessImage(_img1).ToArray();
            harrisPoints2 = harris.ProcessImage(_img2).ToArray();

            // Show the marked points in the original images
            Bitmap img1mark = new PointsMarker(harrisPoints1).Apply(_img1);
            Bitmap img2mark = new PointsMarker(harrisPoints2).Apply(_img2);

            // Concatenate the two images together in a single image (just to show on screen)
            Concatenate concatenate = new Concatenate(img1mark);

            _processImage1 = concatenate.Apply(img2mark);
        }
示例#14
0
        /// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="e">
        /// </param>
        private void BtnHarris_OnClick(object sender, RoutedEventArgs e)
        {
            // Step 1: Detect feature points using Harris Corners Detector
            var harris = new HarrisCornersDetector(0.04f, 1000f);

            this.harrisPoints1 = harris.ProcessImage(this.img1).ToArray();
            this.harrisPoints2 = harris.ProcessImage(this.img2).ToArray();

            // Show the marked points in the original images
            var img1mark = new PointsMarker(this.harrisPoints1).Apply(this.img1);
            var img2mark = new PointsMarker(this.harrisPoints2).Apply(this.img2);

            // Concatenate the two images together in a single image (just to show on screen)
            var concatenate = new Concatenate(img1mark);

            this.PictureBox.Source = (ImageSource)concatenate.Apply(img2mark);
        }
    protected void drawHarrisFeatures(List <Bitmap> imgs)
    {
        List <IntPoint[]> harrisPoints = new List <IntPoint[]>();
        //Calculate all the Harris Points
        HarrisCornersDetector harris = new HarrisCornersDetector(0.03f, 10000f);

        foreach (Bitmap img in imgs)
        {
            harrisPoints.Add(harris.ProcessImage(img).ToArray());
        }

        //Draw & Show all the harris points
        for (int i = 0; i < imgs.Count; i++)
        {
            showImage(new PointsMarker(harrisPoints[i]).Apply(imgs[i]));
        }
    }
示例#16
0
        //---------------------------------------Модуль для обработки Accord (ключевых точек)---------------------------------------//

        void CornerFound(params object[] list)
        {
            if (list.Length != 1)
            {
                double sigma     = (double)list[3];
                double k         = (double)list[1];
                int    threshold = (int)list[2];
                // Create a new Harris Corners Detector using the given parameters
                HarrisCornersDetector harris = new HarrisCornersDetector((float)k)
                {
                    Threshold = (float)threshold,
                    Sigma     = sigma
                };
                // Create a new AForge's Corner Marker Filter
                CornersMarker corners = new CornersMarker(harris, Color.White);
                // input.RotateFlip(RotateFlipType.Rotate180FlipX);
                var    OriginCorner = harris.ProcessImage((Bitmap)list[0]);                     // ОРИГИНАЛ
                var    CornerRrev   = corners.Apply((Bitmap)list[0]);
                var    Picture      = GrayImg.ResizeImg(pictureBox1.Height, pictureBox1.Width); // подгонка для первоначального показа
                Bitmap endpick      = new Bitmap(CornerRrev, new Size(Picture.Item2, Picture.Item1));
                pictureBox1.Image = endpick;
                CreateTable(OriginCorner);// построение таблицы key-точек
            }
            else
            {
                double sigma     = (double)numSigma.Value;
                float  k         = (float)numK.Value;
                float  threshold = (float)numThreshold.Value;
                // Create a new Harris Corners Detector using the given parameters
                HarrisCornersDetector harris = new HarrisCornersDetector(k)
                {
                    Threshold = threshold,
                    Sigma     = sigma
                };
                // Create a new AForge's Corner Marker Filter
                CornersMarker corners = new CornersMarker(harris, Color.White);
                // input.RotateFlip(RotateFlipType.Rotate180FlipX);
                var    OriginCorner = harris.ProcessImage((Bitmap)list[0]);                     // ОРИГИНАЛ
                var    CornerRrev   = corners.Apply((Bitmap)list[0]);
                var    Picture      = GrayImg.ResizeImg(pictureBox1.Height, pictureBox1.Width); // подгонка для первоначального показа
                Bitmap endpick      = new Bitmap(CornerRrev, new Size(Picture.Item2, Picture.Item1));
                pictureBox1.Image = endpick;
                CreateTable(OriginCorner);// построение таблицы key-точек
            }
        }
示例#17
0
        public void ProcessImageTest2()
        {
            UnmanagedImage image = UnmanagedImage.FromManagedImage(Accord.Imaging.Image.Clone(Properties.Resources.sample_black));

            HarrisCornersDetector target = new HarrisCornersDetector(HarrisCornerMeasure.Noble, 700f, 1.4, 1);

            List <IntPoint> actual = target.ProcessImage(image);

            /*
             * PointsMarker marker = new PointsMarker(actual.ToArray());
             * marker.Width = 3;
             * marker.MarkerColor = Color.FromArgb(255, 0, 0);
             * var markers = marker.Apply(image);
             * ImageBox.Show(markers.ToManagedImage(), PictureBoxSizeMode.Zoom);
             */

            Assert.AreEqual(actual.Count, 42);
        }
    protected void drawFastHarrisFeaturesCorrelations(List <Bitmap> imgs)
    {
        List <IntPoint[]> harrisPoints = new List <IntPoint[]>();
        MatrixH           homography;
        //Calculate all the Harris Points
        HarrisCornersDetector harris = new HarrisCornersDetector(0.03f, 10000f);

        foreach (Bitmap img in imgs)
        {
            harrisPoints.Add(harris.ProcessImage(img).ToArray());
        }

        //Map them and draw them!
        Bitmap harrisImg = imgs[0];

        for (int i = 0; i < imgs.Count - 1; i++)
        {
            //Correlate the Harris pts between imgs
            CorrelationMatching matcher = new CorrelationMatching(5, imgs[i], imgs[i + 1]);
            IntPoint[][]        matches = matcher.Match(harrisPoints[i], harrisPoints[i + 1]);

            //Create the homography matrix using ransac
            RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.025, 0.99);
            homography = ransac.Estimate(matches[0], matches[1]);

            Concatenate concat = new Concatenate(harrisImg);
            Bitmap      img    = concat.Apply(imgs[i + 1]);

            Color color = Color.White;
            if (i % 3 == 1)
            {
                color = Color.OrangeRed;
            }
            if (i % 3 == 2)
            {
                color = Color.Blue;
            }
            PairsMarker pairs = new PairsMarker(matches[0].Apply(p => new IntPoint(p.X + harrisImg.Width - imgs[0].Width, p.Y)), matches[1].Apply(p => new IntPoint(p.X + harrisImg.Width, p.Y)), color);
            harrisImg = pairs.Apply(img);
        }

        showImage(harrisImg);
    }
示例#19
0
        public static Geometry AutoAlign(Bitmap needle, Bitmap haystack, double retryThreshold = 1, int retryLimit = 10)
        {
            IntPoint[] harrisPoints1;
            IntPoint[] harrisPoints2;
            IntPoint[] correlationPoints1;
            IntPoint[] correlationPoints2;
            MatrixH    homography;

            var mi1 = new MagickImage(needle); mi1.Equalize(); needle = mi1.ToBitmap();
            var mi2 = new MagickImage(haystack); mi2.Equalize(); haystack = mi2.ToBitmap();

            HarrisCornersDetector harris = new HarrisCornersDetector(0.04f, 20000f);

            harrisPoints1 = harris.ProcessImage(needle).ToArray();
            harrisPoints2 = harris.ProcessImage(haystack).ToArray();

            CorrelationMatching matcher = new CorrelationMatching(9, needle, haystack);

            IntPoint[][] matches = matcher.Match(harrisPoints1, harrisPoints2);

            correlationPoints1 = matches[0];
            correlationPoints2 = matches[1];

            RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.999);

            homography = ransac.Estimate(correlationPoints1, correlationPoints2);

            IntPoint[] inliers1 = correlationPoints1.Get(ransac.Inliers);
            IntPoint[] inliers2 = correlationPoints2.Get(ransac.Inliers);

            Concatenate concat = new Concatenate(needle);
            Bitmap      img3   = concat.Apply(haystack);

            PairsMarker pairs = new PairsMarker(
                inliers1,
                inliers2.Apply(p => new IntPoint(p.X + needle.Width, p.Y)));

            var Image = pairs.Apply(img3);

            Image.Save(@"C:\AutoAlignDebug.png");

            var pointCount = inliers1.Length;

            int[] xList1 = new int[pointCount];
            int[] yList1 = new int[pointCount];
            int[] xList2 = new int[pointCount];
            int[] yList2 = new int[pointCount];

            for (int n = 0; n < pointCount; n++)
            {
                xList1[n] = inliers1[n].X;
                yList1[n] = inliers1[n].Y;
                xList2[n] = inliers2[n].X;
                yList2[n] = inliers2[n].Y;
            }

            var f = new double[8] {
                xList1.Min(), yList1.Min(), xList1.Max(), yList1.Max(), xList2.Min(), yList2.Min(), xList2.Max(), yList2.Max()
            };

            double distFromX1  = f[0] / needle.Width;
            double distFromX2  = f[2] / needle.Width;
            double leftRatio   = f[0] / (f[2] - f[0]);
            double rightRatio  = (needle.Width - f[2]) / (f[2] - f[0]);
            double distFromY1  = f[1] / needle.Height;
            double distFromY2  = f[3] / needle.Height;
            double topRatio    = f[1] / (f[3] - f[1]);
            double bottomRatio = (needle.Height - f[3]) / (f[3] - f[1]);

            double leftDist   = (f[6] - f[4]) * leftRatio;
            double rightDist  = (f[6] - f[4]) * rightRatio;
            double topDist    = (f[7] - f[5]) * topRatio;
            double bottomDist = (f[7] - f[5]) * bottomRatio;

            double x      = f[4] - leftDist;
            double y      = f[5] - topDist;
            double width  = leftDist + (f[6] - f[4]) + rightDist;
            double height = topDist + (f[7] - f[5]) + bottomDist;

            mi1.Resize(new MagickGeometry((int)Math.Round(width), (int)Math.Round(height))
            {
                IgnoreAspectRatio = true
            });
            var mg = new MagickGeometry((int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(width), (int)Math.Round(height))
            {
                IgnoreAspectRatio = true
            };

            mi2.Extent(mg, Gravity.Northwest, MagickColor.FromRgba(0, 0, 0, 0));

            double delta = mi1.Compare(mi2, ErrorMetric.NormalizedCrossCorrelation);

            Geometry outGeo = new Geometry(x, y, width, height);

            if (delta < retryThreshold && retryLimit > 0)
            {
                retryLimit--;
                outGeo = AutoAlign(needle, haystack, delta, retryLimit);
            }

            return(outGeo);
        }
示例#20
0
        //Finds the center coordinate of the part
        //Utilizes Harris Corner Detection from the Accord.Net Library
        //Reference Material:http://accord-framework.net/docs/html/T_Accord_Imaging_HarrisCornersDetector.htm
        public Bitmap findCenter(Bitmap inImage)
        {
            //Creating Harris Corener Dection method
            HarrisCornersDetector cornerDetector = new HarrisCornersDetector(.04f, 100);
            //List of IntPoints containing the found corners
            List <Accord.IntPoint> cornerArray = cornerDetector.ProcessImage(inImage);
            //Creating a temporary bitmap to apply graphics to(Grpahics doesn't accept canny images)
            Bitmap   tempBitmap = new Bitmap(inImage.Width, inImage.Height);
            Graphics g          = Graphics.FromImage(tempBitmap);

            //Redrawing original image on temporary bitmap
            g.DrawImage(inImage, 0, 0);
            Pen aquaPen = new Pen(Color.Aqua, 2.0f);

            //Draws a circle at each found corner
            foreach (Accord.IntPoint p in cornerArray)
            {
                g.DrawEllipse(aquaPen, p.X - 1, p.Y + 1, 2, 2);
            }
            //Finds edges of the part by looking for the minimum and maximum x and y values from found corners
            //IMPORTANT: This does not exculde outlier corners sometimes found in images. These are ussaly eliminated by increasing gama or the light in the overall picture. An outlier remover may be necessary based on conditions
            if (cornerArray.Count > 1)
            {
                int topEdge    = cornerArray[0].Y;
                int bottomEdge = cornerArray[cornerArray.Count - 1].Y;
                int leftEdge   = cornerArray[0].X;
                int rightEdge  = cornerArray[cornerArray.Count - 1].X;


                for (int i = 0; i < cornerArray.Count - 1; i++)
                {
                    if (topEdge > cornerArray[i].Y)
                    {
                        topEdge = cornerArray[i].Y;
                    }
                    if (bottomEdge < cornerArray[i].Y)
                    {
                        bottomEdge = cornerArray[i].Y;
                    }
                    if (leftEdge > cornerArray[i].X)
                    {
                        leftEdge = cornerArray[i].X;
                    }
                    if (rightEdge < cornerArray[i].X)
                    {
                        rightEdge = cornerArray[i].X;
                    }
                }
                //Storing the X and Y dimensions of the part
                xDimensionPixels = Math.Abs(rightEdge - leftEdge);
                yDimensionPixels = Math.Abs(topEdge - bottomEdge);
                //Finding center of the part based on the avearge of the previously found edges
                centerPoint.X = ((int)((leftEdge + rightEdge) / 2.0));
                centerPoint.Y = (int)((topEdge + bottomEdge) / 2.0);
                //Draws a circle at the center point of the image
                g.DrawEllipse(aquaPen, centerPoint.X - 10f, centerPoint.Y - 10f, 20f, 20f);
            }
            //Draws the center and corners if desired by the users
            if (centerCheckbox.Checked)
            {
                cannyImagePanel.Image = tempBitmap;
            }

            return(tempBitmap);
        }