Reputation: 7299
I am trying to apply Sobel filter on my picture to detect edges as you can see here :
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();
}
but the result is very unusual ,i am so new in opencv.
my output
I need this result.
i just need to apply this filter
Upvotes: 1
Views: 11511
Reputation: 7299
thank you all my friend ,i finally found a solution :
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();
Upvotes: 7
Reputation: 3139
According to opencv documentation:
http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/sobel_derivatives/sobel_derivatives.html
you should use the sobel operator in the following way:
Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
The function takes the following arguments:
I hope it support you question.
Upvotes: 2