Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# sobel滤波器在emgucv边缘检测中的应用_C#_C++_Opencv_Image Processing_Emgucv - Fatal编程技术网

C# sobel滤波器在emgucv边缘检测中的应用

C# sobel滤波器在emgucv边缘检测中的应用,c#,c++,opencv,image-processing,emgucv,C#,C++,Opencv,Image Processing,Emgucv,我正在尝试对我的图片应用Sobel过滤器来检测边缘,如您在此处所见: Image<Gray, Byte> imgProcessed1; private void Form1_Load(object sender, EventArgs e) { Image<Bgr, Byte> imgProcessed=new Image<Bgr, byte>(@"C:\Users\Public\Pictures\Sample Pictures\1.jpg");

我正在尝试对我的图片应用Sobel过滤器来检测边缘,如您在此处所见:

Image<Gray, Byte> imgProcessed1;
private void Form1_Load(object sender, EventArgs e)
{



    Image<Bgr, Byte> imgProcessed=new Image<Bgr, byte>(@"C:\Users\Public\Pictures\Sample Pictures\1.jpg");

    imgProcessed1 = imgProcessed.Convert<Gray, byte>();
    Image<Gray, Single> img_final = (imgProcessed1.Sobel(1, 0, 5));
    pictureBox1.Image = img_final.ToBitmap();
}
图像imgProcessed1;
私有void Form1\u加载(对象发送方、事件参数e)
{
Image imgProcessed=新图像(@“C:\Users\Public\Pictures\Sample Pictures\1.jpg”);
imgProcessed1=imgProcessed.Convert();
图像img_final=(imgProcessed1.Sobel(1,0,5));
pictureBox1.Image=img_final.ToBitmap();
}
但是结果很不寻常,我对opencv很陌生

我的输出

我需要这个结果

我只需要应用这个过滤器


根据opencv文档:

应按以下方式使用sobel运算符:

Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
该函数采用以下参数:

  • src_gray:在我们的示例中,输入图像。这是CV_8U
  • grad_x/grad_y:输出图像
  • ddepth:输出图像的深度。我们将其设置为CV_16S以避免 溢出
  • x_阶:导数在x方向上的阶数
  • y_阶:导数在y方向上的阶数
  • 比例、增量和边界默认值:我们使用默认值

  • 我希望它能支持您的问题。

    根据opencv文档:

    应按以下方式使用sobel运算符:

    Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
    
    该函数采用以下参数:

  • src_gray:在我们的示例中,输入图像。这是CV_8U
  • grad_x/grad_y:输出图像
  • ddepth:输出图像的深度。我们将其设置为CV_16S以避免 溢出
  • x_阶:导数在x方向上的阶数
  • y_阶:导数在y方向上的阶数
  • 比例、增量和边界默认值:我们使用默认值

  • 我希望它能支持您的问题。

    谢谢各位朋友,我终于找到了解决方案:

    Image<Gray, byte> gray = new Image<Gray, byte>(@"C:\Users\Public\Pictures\Sample Pictures\1.jpg");
                Image<Gray, float> sobel = gray.Sobel(0, 1, 3).Add(gray.Sobel(1, 0, 3)).AbsDiff(new Gray(0.0));
                pictureBox1.Image = sobel.ToBitmap();
    
    Image gray=新图像(@“C:\Users\Public\Pictures\Sample Pictures\1.jpg”);
    Image sobel=gray.sobel(0,1,3).Add(gray.sobel(1,0,3)).AbsDiff(新灰度(0.0));
    pictureBox1.Image=sobel.ToBitmap();
    
    谢谢各位朋友,我终于找到了解决方案:

    Image<Gray, byte> gray = new Image<Gray, byte>(@"C:\Users\Public\Pictures\Sample Pictures\1.jpg");
                Image<Gray, float> sobel = gray.Sobel(0, 1, 3).Add(gray.Sobel(1, 0, 3)).AbsDiff(new Gray(0.0));
                pictureBox1.Image = sobel.ToBitmap();
    
    Image gray=新图像(@“C:\Users\Public\Pictures\Sample Pictures\1.jpg”);
    Image sobel=gray.sobel(0,1,3).Add(gray.sobel(1,0,3)).AbsDiff(新灰度(0.0));
    pictureBox1.Image=sobel.ToBitmap();
    

    您必须找到准确的水平线和垂直线,因此很难确定使用Sobel运行所需的准确参数。我建议使用Canny,然后使用HoughLines操作来确定哪些线是强垂直线和水平线,您可以通过玩变量来选择角度。@DeJaVo您知道我想在图片上同时应用hor和ver过滤器来检测车牌。我该怎么做?请您首先详细解释一下运行Canny边缘检测,然后运行HoughLines,以获得准确的hor和ver线。然后在Sobel上使用它,并在找到所需输出之前获得正确的角度结果。如果这支持您的问题,请告诉我,如果支持您的问题,我会将其作为答案发布,并请将其标记为解决方案。@DeJaVo谢谢亲爱的朋友我更新了我的帖子您必须找到准确的水平线和垂直线,因此,很难确定使用Sobel运行所需的确切参数。我建议使用Canny,然后使用HoughLines操作来确定哪些线是强垂直线和水平线,您可以通过玩变量来选择角度。@DeJaVo您知道我想在图片上同时应用hor和ver过滤器来检测车牌。我该怎么做?请您首先详细解释一下运行Canny边缘检测,然后运行HoughLines,以获得准确的hor和ver线。然后在Sobel上使用它,并获得正确的角度结果,直到找到所需的输出。让我知道这是否支持您的问题,如果支持,我会将其作为答案发布,并请将其标记为解决方案。@DeJaVo谢谢亲爱的朋友我更新了我的帖子谢谢你关于函数的值我是说src_gray,grad_x,ddepth,比例、增量、边界\u默认我应该使用哪些值?int scale=1;int delta=0;int ddepth=CV_16S;剩下的写在我的答案中。根据你的文档,你应该使用:Sobel(1,2,3)谢谢你,函数的值是什么?我是说src_gray,grad_x,ddepth,scale,delta,BORDER_default我应该使用哪些值?int scale=1;int delta=0;int ddepth=CV_16S;其余部分写在我的答案中。根据您的文档,您应该使用:Sobel(1,2,3)它与其他边缘检测一样简单,但阈值是像素之间的颜色差。它与其他边缘检测一样简单,但阈值是像素之间的颜色差