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


C# Image.MorphologyEx方法代码示例

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


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

示例1: TestMorphEx

 public void TestMorphEx()
 {
     StructuringElementEx element1 = new StructuringElementEx(3, 3, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
      StructuringElementEx element2 = new StructuringElementEx(new int[3, 3] { { 0, 1, 0 }, { 1, 0, 1 }, { 0, 1, 0 } }, 1, 1);
      Image<Bgr, Byte> tmp = new Image<Bgr, byte>(100, 100);
      Image<Bgr, Byte> tmp2 = tmp.MorphologyEx(element1, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_GRADIENT, 1);
      Image<Bgr, Byte> tmp3 = tmp.MorphologyEx(element2, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_BLACKHAT, 1);
 }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:8,代码来源:AutoTestVarious.cs

示例2: _testSobelParameters

        public void _testSobelParameters(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration, int cols, int rows, int anchorX, int anchorY, int shape)
        {
            int xOrder = 0, yOrder = 0, appetureSize = 1;
            for (appetureSize = 3; appetureSize < 8; appetureSize += 2)
            {
                for (xOrder = 0; xOrder < appetureSize-1; xOrder++)
                    for (yOrder = 0; yOrder < appetureSize-1; yOrder++)
                    {
                        img = img.Sobel(xOrder, yOrder, appetureSize);
                        StructuringElementEx element;
                        if (shape == 0)
                            element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
                        else if (shape == 1)
                            element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
                        else
                            element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);

                        img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
                        img = img.Rotate(90.0, new Gray(255), false);
                        img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
                        img = img.Rotate(-90.0, new Gray(255), false);
                        if (threshold >= 0 && threshold <= maxGrayVal)
                        {
                            img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
                        }
                        else
                        {
                            MessageBox.Show("Threshold is not appropriate, please choose another!");
                        }
                        img.Bitmap.Save(@"Sobel\" + xOrder + " " + yOrder + " " + appetureSize + ".png");
                    }
            }
        }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:33,代码来源:BlindSpot_Util.cs

示例3: _testMorphological

        private Image<Gray, Single> _testMorphological(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration, int cols, int rows, int anchorX, int anchorY, int shape)
        {
            img = img.Sobel(0, 1, 3);
            StructuringElementEx element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT); ;
            if (shape == 1)
                element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
            else if (shape == 2)
                element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);

            img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
            img = img.Rotate(90.0, new Gray(255), false);
            img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
            img = img.Rotate(-90.0, new Gray(255), false);
            if (threshold >= 0 && threshold <= maxGrayVal)
            {
                img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
            }
            else
            {
                MessageBox.Show("Threshold is not appropriate, please choose another!");
            }
            return img;
        }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:23,代码来源:BlindSpot_Util.cs

示例4: _testMorphological

        private Image<Gray, Single> _testMorphological(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration, int cols, int rows, int anchorX, int anchorY, int shape)
        {
            int xOrder = Int32.Parse(txtXorder.Text), yOrder = Int32.Parse(txtYorder.Text),
                appetureSize = Int32.Parse(txtAppetureSize.Text);
            //img = img.Sobel(0, 1, 5);
            //img = img.Sobel(xOrder, yOrder, appetureSize);
            img = sobel_Filter(img);

            StructuringElementEx element;
            if(shape==0)
            element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
            else if (shape == 1)
                element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_CROSS);
            else
                element = new StructuringElementEx(cols, rows, anchorX, anchorY, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);

            img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
            img = img.Rotate(90.0, new Gray(255), false);
            img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
            img = img.Rotate(-90.0, new Gray(255), false);
            if (threshold >= 0 && threshold <= maxGrayVal)
            {
                img = img.ThresholdBinary(new Gray(threshold), new Gray(255));
            }
            else
            {
                MessageBox.Show("Threshold is not appropriate, please choose another!");
            }
            //img.Bitmap.Save(@"Sobel\" + xOrder + " " + yOrder + " " + appetureSize + ".png");
            return img;
        }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:31,代码来源:Form1.cs

示例5: _imageProcessing

 /// <summary>
 /// 
 /// </summary>
 /// <param name="img">Input Image</param>
 /// <param name="threshold">Threshold value (with 8-bit image is from 0 to 255)</param>
 /// <param name="maxGrayVal">Maximum Gray Value</param>
 /// <param name="closingIteration">number of Iterations</param>
 /// <returns>Processed Image</returns>
 public Image<Gray, Single> _imageProcessing(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration)
 {
     img = img.Sobel(0, 1, 3);
     StructuringElementEx element = new StructuringElementEx(3, 3, -1, -1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE);
     img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
     img = img.Rotate(-90.0, new Gray(255), false);
     img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
     img = img.Rotate(90.0, new Gray(255), false);
     if (threshold >= 0 && threshold <= maxGrayVal)
     {
         img = img.ThresholdBinary(new Gray(threshold), new Gray(maxGrayVal));
     }
     else
     {
         //MessageBox.Show("Threshold is not appropriate, please choose another!");
         throw new ArgumentOutOfRangeException("Threshold is not appropriate, please choose another threshold value!");
     }
     return img;
 }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:27,代码来源:BlindSpot_Util.cs

示例6: _imageProcessing

 /// <summary>
 /// 
 /// </summary>
 /// <param name="img">Input Image</param>
 /// <param name="threshold">Threshold value (with 8-bit image is from 0 to 255)</param>
 /// <param name="maxGrayVal">Maximum Gray Value</param>
 /// <param name="closingIteration">number of Iterations</param>
 /// <returns></returns>
 private Image<Gray, Single> _imageProcessing(Image<Gray, Single> img, int threshold, int maxGrayVal, int closingIteration)
 {
     img = img.Sobel(0, 1, 4);
     StructuringElementEx element = new StructuringElementEx(4, 4, 1, 1, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
     //MessageBox.Show((int)Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE + "");
     img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
     img = img.Rotate(90.0, new Gray(maxGrayValue), false);
     img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
     img = img.Rotate(-90.0, new Gray(maxGrayValue), false);
     if (threshold >= 0 && threshold <= maxGrayVal)
     {
         img = img.ThresholdBinary(new Gray(threshold), new Gray(maxGrayValue));
     }
     else
     {
         MessageBox.Show("Threshold is not appropriate, please choose another!");
     }
     return img;
 }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:27,代码来源:Form1.cs

示例7: morfologyEx

 private Image<Gray, Single> morfologyEx(Image<Gray, Single> img)
 {
     StructuringElementEx element = new StructuringElementEx(5, 5, 3, 3, Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_RECT);
     img = img.MorphologyEx(element, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, closingIteration);
     return img;
 }
开发者ID:mrcancer91,项目名称:Driving-Bind-Spot,代码行数:6,代码来源:Form1.cs

示例8: TestMorphEx

 public void TestMorphEx()
 {
    Mat kernel1 = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Cross, new Size(3, 3), new Point(1, 1));
    Matrix<byte> kernel2 = new Matrix<byte>(new Byte[3, 3] { { 0, 1, 0 }, { 1, 0, 1 }, { 0, 1, 0 } });
    //StructuringElementEx element2 = new StructuringElementEx(new int[3, 3] { { 0, 1, 0 }, { 1, 0, 1 }, { 0, 1, 0 } }, 1, 1);
    Image<Bgr, Byte> tmp = new Image<Bgr, byte>(100, 100);
    Image<Bgr, Byte> tmp2 = tmp.MorphologyEx(Emgu.CV.CvEnum.MorphOp.Gradient, kernel1, new Point(-1, -1), 1, CvEnum.BorderType.Default, new MCvScalar());
    Image<Bgr, Byte> tmp3 = tmp.MorphologyEx(Emgu.CV.CvEnum.MorphOp.Gradient, kernel2, new Point(-1, -1), 1, CvEnum.BorderType.Default, new MCvScalar());
    //Image<Bgr, Byte> tmp2 = tmp.MorphologyEx(element1, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_GRADIENT, 1);
    //Image<Bgr, Byte> tmp3 = tmp.MorphologyEx(element2, Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_BLACKHAT, 1);
 }
开发者ID:Delaley,项目名称:emgucv,代码行数:11,代码来源:AutoTestVarious.cs

示例9: MorphologyClosing

      public static Image<Gray, Byte> MorphologyClosing(Image<Gray, Byte> img, int radius)
      {
         int kernelSize = radius * 2 + 1;
         byte[,] kernelMat = new byte[kernelSize, kernelSize];
         for (int i = 0; i < kernelSize; i++)
            for (int j = 0; j < kernelSize; j++)
            {
               double dx = i - (radius);
               double dy = j - (radius);
               double dist = Math.Sqrt(dx * dx + dy * dy);
               if (dist <= radius)
               {
                  kernelMat[i, j] = 1;
               }
            }

         //for definition on the close operation, see.
         //http://en.wikipedia.org/wiki/Mathematical_morphology
         using (Matrix<byte> kernel = new Matrix<byte>(kernelMat))
         {
            return img.MorphologyEx(CvEnum.MorphOp.Close, kernel, new Point(-1, -1), 1, CvEnum.BorderType.Default, new MCvScalar());
         }
         //using (StructuringElementEx e = new StructuringElementEx(kernelMat, radius, radius))
         //{
         //return img.MorphologyEx(e, CvEnum.CV_MORPH_OP.CV_MOP_CLOSE, 1);
         //}
      }
开发者ID:neutmute,项目名称:emgucv,代码行数:27,代码来源:AutoTestImage.cs

示例10: preProcessImage

        private static Image<Gray, byte> preProcessImage(
            Image<Gray, byte> gImage,
            int para1,
            int para2)
        {
            //Image<Gray, byte> gImage = frame.Convert<Gray, byte>();
            //gImage = gImage.ConvertScale<byte>(0.25, 0);
            //Image<Gray, byte> gImage2 = gImage.Clone();
            //gImage2 = gImage2.SmoothBlur((int)para2, (int)para2);
            //gImage2 = gImage2.Not();
            //gImage = gImage.AddWeighted(gImage2, 1, 0.5, 0);
            //gImage._EqualizeHist();
            gImage = gImage.Resize(0.25, INTER.CV_INTER_NN);
            gImage = gImage.SmoothBlur(11, 11);
            gImage = gImage.ThresholdBinary(new Gray(para1), new Gray(255));

            //gImage = gImage.ThresholdAdaptive(
            //    new Gray(255),
            //    Emgu.CV.CvEnum.ADAPTIVE_THRESHOLD_TYPE.CV_ADAPTIVE_THRESH_MEAN_C,
            //    Emgu.CV.CvEnum.THRESH.CV_THRESH_BINARY,
            //    para1,
            //    new Gray(para2)
            //);

            gImage = gImage.MorphologyEx(
                new StructuringElementEx(
                    3,
                    (int)para2,
                    1,
                    (int)para2 / 2,
                    Emgu.CV.CvEnum.CV_ELEMENT_SHAPE.CV_SHAPE_ELLIPSE),
                    Emgu.CV.CvEnum.CV_MORPH_OP.CV_MOP_OPEN,
                    1);

            gImage = gImage.Resize(4, INTER.CV_INTER_NN);
            return gImage;
        }
开发者ID:hermanliang,项目名称:RatWalk,代码行数:37,代码来源:Form1.cs


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