Exemple #1
0
        private System.Windows.Point GetEdgePoint(System.Windows.Controls.Image rawImage, System.Windows.Controls.Image overlayImage)
        {
            Bitmap            rawbmp      = LoadImagetoBMP(rawImage);
            Bitmap            filteredbmp = FilterImage(rawbmp);
            Image <Bgr, Byte> rawImg      = new Image <Bgr, Byte>(rawbmp);

            rawImg = rawImg.SmoothGaussian(3, 3, .1, .1);
            rawImg.Save("TestRawImage.jpg");
            Image <Gray, Byte> filteredImg = rawImg.Canny(80.0, 200.0);

            filteredImg.Save("TestFiltered.jpg");

            EdgeDetection edge = new EdgeDetection();

            edge.bitmap = filteredImg.ToBitmap();
            System.Drawing.Point start = new System.Drawing.Point();
            System.Drawing.Point end   = new System.Drawing.Point();

            start.X = (int)_startPoint.X;
            start.Y = (int)_startPoint.Y;
            end.X   = (int)_endPoint.X;
            end.Y   = (int)_endPoint.Y;

            edge.CreateParametricLine(start, end);

            List <System.Drawing.Color> colorList = new List <System.Drawing.Color>();
            List <PointF> points = new List <PointF>();

            edge.GetPixelsPoints(colorList, points);
            int           indexMaxPoint    = edge.FindMaxPixelIntensity(colorList);
            List <double> colorGradient    = edge.GetGradientPoints(colorList);
            int           indexMaxGradient = edge.FindMaxGradient(colorGradient);

            Bitmap overlaybmp = LoadImagetoBMP(overlayImage);

            DrawEllipse(overlaybmp, points[indexMaxGradient]);

            overlayImage.Source = LoadBMPtoImage(overlaybmp);

            System.Windows.Point imagePoint = new System.Windows.Point(points[indexMaxGradient].X, points[indexMaxGradient].Y);
            return(imagePoint);
        }