2015-12-27 118 views
0

我想對我的照片應用索貝爾過濾器檢測邊緣,你可以在這裏看到:應用Sobel濾波器的邊緣檢測在emgucv

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(); 
} 

但結果是非常不尋常的,我在OpenCV的太新。

我的輸出

enter image description here

我需要這個結果。

enter image description here

我只需要應用此過濾器

enter image description here

+0

你必須要找到確切的水平線和垂直線,所以很難確定需要與索貝爾運行的確切參數。 我會建議使用Canny,然後使用HoughLines操作來確定哪些線條是強烈的垂直和水平線條,您可以通過玩變量來選擇角度。 – DeJaVo

+0

@DeJaVo你知道我想在我的圖片上應用hor和ver過濾器來檢測牌照。我可以這樣做嗎?請你詳細解釋一下 –

+0

首先運行Canny邊緣檢測,然後HoughLines爲了獲得確切的hor和ver行。然後在Sobel上使用它,並以角度獲得適當的結果,直到找到所需的輸出。 – DeJaVo

回答

4

謝謝我所有的朋友,我終於找到了解決辦法:

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(); 
+0

但實際上我不知道它是如何工作的, –

+0

它的簡單像其他邊緣檢測一樣,但閾值是像素之間的差異顏色值 –

2

據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); 

該函數採用下列參數:

  1. src_gray:在我們的例子中,輸入圖像。這裏是CV_8U
  2. grad_x/grad_y:輸出圖像。
  3. ddepth:輸出圖像的深度。我們將其設置爲CV_16S以避免 溢出。
  4. x_order:x方向上的導數的階數。
  5. y_order:y方向導數的階數。
  6. 比例,增量和BORDER_DEFAULT:我們使用默認值。

我希望它支持你的問題。

+0

謝謝你的函數值是什麼意思我的意思是src_gray,grad_x,ddepth,scale,delta,BORDER_DEFAULT –

+0

我應該使用哪些值? –

+0

int scale = 1; int delta = 0; int ddepth = CV_16S; 其餘的是寫在我的答案。 – DeJaVo