在 emgucv 中应用 sobel 滤波器进行边缘检测
Apply sobel filter for edge detection in 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.jpg");
imgProcessed1 = imgProcessed.Convert<Gray, byte>();
Image<Gray, Single> img_final = (imgProcessed1.Sobel(1, 0, 5));
pictureBox1.Image = img_final.ToBitmap();
}
但是结果很不寻常,我是opencv的新手。
我的输出
我需要这个结果。
我只需要应用这个过滤器
根据 opencv 文档:
http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/sobel_derivatives/sobel_derivatives.html
您应该按以下方式使用 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_order:x方向导数的阶数
- y_order:y方向导数的阶数
- scale、delta 和 BORDER_DEFAULT:我们使用默认值。
我希望它能支持你的问题。
谢谢所有朋友,我终于找到了解决方案:
Image<Gray, byte> gray = new Image<Gray, byte>(@"C:\Users\Public\Pictures\Sample Pictures.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();
我正尝试在我的图片上应用 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.jpg");
imgProcessed1 = imgProcessed.Convert<Gray, byte>();
Image<Gray, Single> img_final = (imgProcessed1.Sobel(1, 0, 5));
pictureBox1.Image = img_final.ToBitmap();
}
但是结果很不寻常,我是opencv的新手。
我的输出
我需要这个结果。
我只需要应用这个过滤器
根据 opencv 文档:
http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/sobel_derivatives/sobel_derivatives.html
您应该按以下方式使用 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_order:x方向导数的阶数
- y_order:y方向导数的阶数
- scale、delta 和 BORDER_DEFAULT:我们使用默认值。
我希望它能支持你的问题。
谢谢所有朋友,我终于找到了解决方案:
Image<Gray, byte> gray = new Image<Gray, byte>(@"C:\Users\Public\Pictures\Sample Pictures.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();