当前位置: 首页>>代码示例>>C#>>正文


C# Image.Canny方法代码示例

本文整理汇总了C#中Image.Canny方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Canny方法的具体用法?C# Image.Canny怎么用?C# Image.Canny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image.Canny方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Canny

 public Bitmap Canny(Bitmap image)
 {
     Image<Gray, Byte> cannyimg = new Image<Gray, Byte>(image);
        // cannyimg = cannyimg.Canny(10, 19);
        cannyimg = cannyimg.Canny(13, 45);
     return cannyimg.ToBitmap();
 }
开发者ID:Quan311294,项目名称:Vessel-Detection,代码行数:7,代码来源:Filters.cs

示例2: Run

        public void Run()
        {
            base.Start();

            base.Output = new cImage(base.Input, false);

            for (int IdxChannel = 0; IdxChannel < base.ListChannelsToBeProcessed.Count; IdxChannel++)
            {
                int CurrentChannel = base.ListChannelsToBeProcessed[IdxChannel];

                Image<Gray, float> inputImage = new Image<Gray, float>(Input.Width, Input.Height);

                for (int j = 0; j < Input.Height; j++)
                    for (int i = 0; i < Input.Width; i++)
                        inputImage.Data[j, i, 0] = Input.SingleChannelImage[CurrentChannel].Data[i + j * Input.Width];

                Image<Gray, byte> ProcessedImage = new Image<Gray, byte>(inputImage.Width, inputImage.Height);
                ProcessedImage = inputImage.Canny(GreyThreshold, GreyThresholdLinkin);

                this.Output.SingleChannelImage[IdxChannel].SetNewDataFromOpenCV(ProcessedImage);
            }

            base.End();

            return;
        }
开发者ID:cyrenaique,项目名称:HCSA,代码行数:26,代码来源:cImageFilterCanny.cs

示例3: FilterPlate

        private static Image<Gray, Byte> FilterPlate(Image<Gray, Byte> plate)
        {
            Image<Gray, Byte> thresh = plate.ThresholdBinaryInv(new Gray(120), new Gray(255));

            Image<Gray, Byte> plateMask = new Image<Gray, byte>(plate.Size);
            Image<Gray, Byte> plateCanny = plate.Canny(new Gray(100), new Gray(50));
            MemStorage stor = new MemStorage();
            {
                plateMask.SetValue(255.0);
                for (
                   Contour<Point> contours = plateCanny.FindContours(
                      Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
                      Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL,
                      stor);
                   contours != null; contours = contours.HNext)
                {
                    Rectangle rect = contours.BoundingRectangle;
                    if (rect.Height > (plate.Height >> 1))
                    {
                        rect.X -= 1; rect.Y -= 1; rect.Width += 2; rect.Height += 2;
                        rect.Intersect(plate.ROI);

                        plateMask.Draw(rect, new Gray(0.0), -1);
                    }
                }

                thresh.SetValue(0, plateMask);
            }

            thresh._Erode(1);
            thresh._Dilate(1);

            return thresh;
        }
开发者ID:donie81,项目名称:ia-licence-plate-detection,代码行数:34,代码来源:Form1.cs

示例4: ExtractContour

 public List<LineSegment2D> ExtractContour(Image<Bgr, byte> img,out Image<Bgr, byte> temp )
 {
     List<LineSegment2D> ListOfLines = new List<LineSegment2D>();
     Image<Gray, byte> gray = new Image<Gray, byte>(img.ToBitmap());
     gray.ThresholdBinary(new Gray(149), new Gray(255));
     gray._Dilate(1);
     gray._Erode(1);
     img.ROI = new Rectangle(new Point(0, Img_Height - Roi_Height), new Size(Img_Width, Roi_Height));
     gray.ROI = new Rectangle(new Point(0, Img_Height - Roi_Height), new Size(Img_Width, Roi_Height));
     Image<Gray, byte> canny = gray.Canny(150, 50);
     //canny.Save("D:\\temp\\canny.jpg");
     Image<Bgr, byte> lineimage = img;
     lines = canny.HoughLines(1, 2, 3, Math.PI / 180, 150, 80, 400);
     foreach (LineSegment2D line in lines[0])
     {
         float theta = line.Direction.Y / line.Direction.X;
         float c = line.P1.Y - theta * line.P1.X;
         if (Math.Abs(theta) > 0.1 && Math.Abs(theta) < 0.9&&c<300)
         {
             lineimage.Draw(line, new Bgr(0, 0, 255), 1);
             ListOfLines.Add(line);
         }
     }
     temp = lineimage;
     //lineimage.Save("D:\\temp\\HoughLines.jpg");
     return ListOfLines;
 }
开发者ID:kylezhaoxc,项目名称:RoadTracer-EmguCv,代码行数:27,代码来源:LineHelper.cs

示例5: getEdge

 protected static List<Point> getEdge(Image<Gray, Byte> img)
 {
     var canny = img.Canny(new Gray(50), new Gray(50));
     List<Point> edge = new List<Point>();
     for (int y = 0; y < canny.Height; ++y) {
         for (int x = 0; x < canny.Width; ++x) {
             if (canny[y, x].Intensity > 0) {
                 edge.Add(new Point(x, y));
             }
         }
     }
     return edge;
 }
开发者ID:pakerliu,项目名称:sharp-context,代码行数:13,代码来源:TestBase.cs

示例6: processFrameAndUpdateGUI

        ///////////////////////////////////////////////////////////////////////////////////////////
        void processFrameAndUpdateGUI(object sender, EventArgs arg)
        {
            imgOriginal = capWebcam.QueryFrame();               // get next frame from the webcam

            if (imgOriginal == null)                            // if we did not get a frame
            {                                                   // show error via message box
                MessageBox.Show("unable to read from webcam" + Environment.NewLine + Environment.NewLine +
                                "exiting program");
                Environment.Exit(0);                            // and exit program
            }
            imgGrayscale = imgOriginal.Convert<Gray, Byte>();       // convert to grayscale
            imgBlurred = imgGrayscale.SmoothGaussian(5);            // blur

            double dblCannyThresh = 150.0;                          // declare params for call to Canny
            double dblCannyThreshLinking = 75.0;                    //

            imgCanny = imgBlurred.Canny(dblCannyThresh, dblCannyThreshLinking);     // get Canny edges

            ibOriginal.Image = imgOriginal;             // update image boxes
            ibCanny.Image = imgCanny;                   //
        }
开发者ID:almar12,项目名称:OpenCV_2.4.11_Windows_Installation_Guide,代码行数:22,代码来源:CannyWebcam.cs

示例7: CountContours

        public int CountContours(Bitmap temp)
        {
            ///<summary>return the number of contours in the image</summary>
            /// <param name="temp">bitmap image, contains only the contour.</param>
            ///
            var contourNumber = 0;
            var gray = new Image<Gray, byte>(temp);
            gray.ThresholdBinary(new Gray(149), new Gray(255));
            gray._Dilate(1);
            gray._Erode(1);
            Contour<Point> contours;
            using (var canny = gray.Canny(150, 50))
            {
                var stor = new MemStorage();
                contours = canny.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_CCOMP, stor);
            }
            if (contours == null) return 0;
            for (; contours != null; contours = contours.HNext)
            {
                contourNumber++;
            }

            return contourNumber;
        }
开发者ID:kylezhaoxc,项目名称:Kyle_Emgu,代码行数:24,代码来源:SurfProcessor.cs

示例8: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();
            using (new MPI.Environment(ref args))
            {
                Intracommunicator comm = Communicator.world;

                try
                {
                    stopwatch.Start();

                    imgOriginal = new Image<Bgr, Byte>(".\\Humerus\\1.bmp");
                    imgGray = imgOriginal.Convert<Gray, Byte>();
                    imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                    imgGray = imgGray.ThresholdToZero(new Gray(100));
                    imgGray = imgGray.SmoothGaussian(9);
                    imgGray = imgGray.Canny(0, 80);
                    Lb_Rank.Text = comm.Rank.ToString();

                    heigh = imgGray.Height;
                    width = imgGray.Width;
                    bitmap = new Bitmap(imgGray.ToBitmap());
                    Bitmap New_Bitmap = new Bitmap(width, heigh / comm.Size);
                    count_pixel = 0;
                    int a = 0;
                    int b = 0;
                    int m = 0;
                    for (int i = (heigh / comm.Size) * comm.Rank; i < (heigh / comm.Size) * (comm.Rank+1); i++) // row, y
                    //for (int i = (heigh /2) * 1; i < (heigh / 2) * (1 + 1); i++) // row, y
                    {
                        for (int j = 0; j < width; j++)  // collumn, x
                        {
                            Console.Write("(" + i.ToString() + "," + j + "),");
                            a = (j + Start_Pixel_x);
                            b = (i + Start_Pixel_y);
                            Color pixel = bitmap.GetPixel(a, b);
                            if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255) //RGB is white then count
                            {
                                count_pixel++;
                                bitmap.SetPixel(a, b, Vector_Color);    // color new vector with Red
                                New_Bitmap.SetPixel(j,m, Color.Red);
                                Find_Boundary_List(a, b, New_Bitmap, comm,m); // find boundary area
                            }
                        }
                        m++;

                    }

                    picTemp.Image = New_Bitmap;
                    Lb_Parallel_Line.Text = count_line_parallel.ToString();
                    if (count_line_parallel == 2)
                    {
                        Lb_Broken.ForeColor = Color.Blue;
                        Lb_Broken.Text = "Non Broken";
                    }
                    else
                    {
                        Lb_Broken.ForeColor = Color.Red;
                        Lb_Broken.Text = "Broken";
                    }

                    //////////////////////////////////////////////
                    stopwatch.Stop();
                    Lb_Time.Text = stopwatch.ElapsedMilliseconds.ToString();
                    Console.WriteLine("End rank " + comm.Rank.ToString() + " From1_load" + DateTime.Now +
                        " take time " + stopwatch.ElapsedMilliseconds.ToString() + "  milliseconds\n");
                    //Console.WriteLine("End rank 1"  + " From1_load" + DateTime.Now +
                    //    " take time " + stopwatch.ElapsedMilliseconds.ToString() + "  milliseconds\n");

                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message.ToString()); }
            }
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:74,代码来源:Form1.cs

示例9: start

        public int start(Communicator comm)
        {
            int Vote = 0;

            try
            {
                Vote = LoadAndProcessImage(".\\Humerus\\1.bmp",comm);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }

            ibImage.SizeMode = PictureBoxSizeMode.Zoom;
            imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
            imgGray = imgGray.ThresholdToZero(new Gray(100));
            imgGray = imgGray.SmoothGaussian(9);
            imgGray = imgGray.Canny(0, 80);

            return Vote;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:23,代码来源:Form1.cs

示例10: StartDye

        public void StartDye(int X, int Y, int Heigh, int Width, Image<Gray, Byte> ImgGray, Communicator comm)
        {
            // Console.WriteLine("start StartDye");
            heigh = Heigh;
            width = Width;
            Start_Pixel_x = X;
            Start_Pixel_y = Y;
            imgGray = ImgGray;

            if (width <= 24) //elliminate noise 67,24
            { Flag = false; }
            else
            {
            //ArrayList Set_Pixel_In_Row = new ArrayList(); // Array for college
            imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
            imgGray = imgGray.ThresholdToZero(new Gray(100));
            imgGray = imgGray.SmoothGaussian(9);
            imgGray = imgGray.Canny(0, 80);
            bitmap = new Bitmap(imgGray.ToBitmap());
            count_line_parallel = 0;
            //Initial_Dye_Pixel(comm);
            Flag = true;
            }
            //Console.WriteLine("end StartDye");
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:25,代码来源:Form1.cs

示例11: LoadAndProcessImage

        public bool LoadAndProcessImage(string FileName)
        {
            bool Broken = false;
            imgOriginal = new Image<Bgr, Byte>(FileName);
            imgGray = imgOriginal.Convert<Gray, Byte>();
            //BitAnalysis.StartDye(0, 0, imgGray.Height, imgGray.Width, imgGray);

            hcHumerus = new HaarCascade(@"c:\haarHumerus_03112013_4.8_18.xml"); //haarHumerus_03112013_4.8_18
            ibImage.Image = imgBlank;

            acHumerus = hcHumerus.Detect(imgGray,
                        4.8,
                        18,
                        HAAR_DETECTION_TYPE.SCALE_IMAGE,
                        Size.Empty,
                        Size.Empty);
            acHumerus1 = hcHumerus.Detect(imgGray,
                                        4.8,
                                        18,
                                        HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                        Size.Empty,
                                        Size.Empty);

            int count1 = 0, count2 = 0;
            PB.Value += 10;
            foreach (MCvAvgComp acHum in acHumerus)
            {
                if (GetCoordination(acHum))  // to get coordination x,y, and with, high
                {
                    imgOriginal.Draw(acHum.rect, new Bgr(Color.Blue), 2);
                    count1++;
                    Broken = true;
                }
                imgGray.Draw(acHum.rect, new Gray(0.0), 1);
            }
            PB.Value += 10;
            if (count1 == 0)
            {
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    if (GetCoordination(acHum1))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Red), 2);
                        count2++;
                        Broken = true;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(0.0), 1);
                }
            }
            if (count1 == 0  && count2 == 0 )
            {
                imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                imgGray = imgGray.ThresholdToZero(new Gray(100));
                imgGray = imgGray.SmoothGaussian(9);
                imgGray = imgGray.Canny(0, 80);

                hcHumerus = new HaarCascade(@"c:\HaarHumerus_03172013_2.8_3.xml");

                acHumerus = hcHumerus.Detect(imgGray,
                   2.8,
                   3,
                    HAAR_DETECTION_TYPE.SCALE_IMAGE,
                    Size.Empty,
                    Size.Empty);
                acHumerus1 = hcHumerus.Detect(imgGray,
                    2.8,
                    3,
                    HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                    Size.Empty,
                    Size.Empty);
                foreach (MCvAvgComp acHum in acHumerus)
                {
                    if (GetCoordination(acHum))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum.rect, new Bgr(Color.Orange), 2);
                        Broken = true;
                    }
                    imgGray.Draw(acHum.rect, new Gray(0.0), 1);
                }
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {

                    if (GetCoordination(acHum1))  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Green), 2);
                        Broken = true;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(), 1);
                }

            }
            PB.Value = +20;

            return Broken;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysis,代码行数:95,代码来源:Form1.cs

示例12: LoadAndProcessImage

        public int LoadAndProcessImage(string FileName, Communicator comm)
        {
            int Vote = 0;
            imgOriginal = new Image<Bgr, Byte>(FileName);
            imgGray = imgOriginal.Convert<Gray, Byte>();
            //BitAnalysis.StartDye(0, 0, imgGray.Height, imgGray.Width, imgGray);

            hcHumerus = new HaarCascade(".\\haarHumerus_03112013_4.8_18.xml");
            ibImage.Image = imgBlank;

            acHumerus = hcHumerus.Detect(imgGray,
                        4.8,
                        18,
                        HAAR_DETECTION_TYPE.SCALE_IMAGE,
                        Size.Empty,
                        Size.Empty);
            acHumerus1 = hcHumerus.Detect(imgGray,
                                        4.8,
                                        18,
                                        HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                        Size.Empty,
                                        Size.Empty);

            int count1 = 0, count2 = 0;
            foreach (MCvAvgComp acHum in acHumerus)
            {
                StartDye(acHum.rect.X, acHum.rect.Y, acHum.rect.Width, acHum.rect.Height, imgGray,comm);
                if (Flag)  // to get coordination x,y, and with, high
                {
                    imgOriginal.Draw(acHum.rect, new Bgr(Color.Blue), 2);
                    count1++;
                    Vote = 1;
                }
                imgGray.Draw(acHum.rect, new Gray(0.0), 1);
            }
            if (count1 ==0)
            {
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    StartDye(acHum1.rect.X, acHum1.rect.Y, acHum1.rect.Width, acHum1.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Red), 2);
                        count2++;
                        Vote = 1;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(0.0), 1);
                }
            }
            if (count1 == 0 &&  count2 == 0 )
            {
                imgGray = imgGray.AddWeighted(imgGray, 1.0, 0.0, 0.0);
                imgGray = imgGray.ThresholdToZero(new Gray(100));
                imgGray = imgGray.SmoothGaussian(9);
                imgGray = imgGray.Canny(0, 80);

                hcHumerus = new HaarCascade(".\\HaarHumerus_03172013_2.8_3.xml");

                acHumerus = hcHumerus.Detect(imgGray,
                   2.8,
                   3,
                    HAAR_DETECTION_TYPE.SCALE_IMAGE,
                    Size.Empty,
                    Size.Empty);
                acHumerus1 = hcHumerus.Detect(imgGray,
                    2.8,
                    3,
                    HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                    Size.Empty,
                    Size.Empty);
                foreach (MCvAvgComp acHum in acHumerus)
                {
                    StartDye(acHum.rect.X, acHum.rect.Y, acHum.rect.Width, acHum.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum.rect, new Bgr(Color.Orange), 2);
                        Vote = 1;
                    }
                    imgGray.Draw(acHum.rect, new Gray(0.0), 1);
                }
                foreach (MCvAvgComp acHum1 in acHumerus1)
                {
                    StartDye(acHum1.rect.X, acHum1.rect.Y, acHum1.rect.Width, acHum1.rect.Height, imgGray,comm);
                    if (Flag)  // to get coordination x,y, and with, high
                    {
                        imgOriginal.Draw(acHum1.rect, new Bgr(Color.Green), 2);
                        Vote = 1;
                    }
                    imgGray.Draw(acHum1.rect, new Gray(), 1);
                }

            }

            return Vote;
        }
开发者ID:RBChavez,项目名称:HumerusAnalysisParallelComputing,代码行数:95,代码来源:Form1.cs

示例13: TestContour

        public void TestContour()
        {
            Image<Gray, Byte> img = new Image<Gray, byte>("stuff.jpg");
             img.SmoothGaussian(3);
             img = img.Canny(new Gray(80), new Gray(50));
             Image<Gray, Byte> res = img.CopyBlank();
             res.SetValue(255);

             Contour<Point> contour = img.FindContours();

             while (contour != null)
             {
            Contour<Point> approx = contour.ApproxPoly(contour.Perimeter * 0.05);

            if (approx.Convex && approx.Area > 20.0)
            {
               Point[] vertices = approx.ToArray();

               LineSegment2D[] edges = PointCollection.PolyLine(vertices, true);

               res.DrawPolyline(vertices, true, new Gray(200), 1);
            }
            contour = contour.HNext;
             }
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:25,代码来源:AutoTestImage.cs

示例14: GetCannyEdges

 private static Image<Gray, Byte> GetCannyEdges(Image<Gray, Byte> gray)
 {
     double cannyThreshold = 60;
       double cannyThresholdLinking = 60;
       Gray circleAccumulatorThreshold = new Gray(120);
       Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);
       return cannyEdges;
 }
开发者ID:hcilab-um,项目名称:tPad,代码行数:8,代码来源:MainWindow.xaml.cs

示例15: TestCanny

        public void TestCanny()
        {
            Image<Bgr, Byte> image = new Image<Bgr, byte>("stuff.jpg");

             //make sure canny works for multi channel image
             Image<Bgr, Byte> image2 = image.Canny(new Bgr(200, 200, 200), new Bgr(100, 100, 100));

             Size size = image2.Size;
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:9,代码来源:AutoTestImage.cs


注:本文中的Image.Canny方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。