2014-03-19 216 views
0

我想要将垂直和水平边缘连接在一起以获取图像中的所有边缘,以便将其用于Harris角点检测。边缘幅度(垂直和水平边缘)

我使用索贝尔过滤器,以获得垂直和水平边缘:

I = imread('CleanFingerprint.jpg'); // read the image 
I = im2double(I); // convert it to double 
G = rgb2gray(I); // convert it to gray 

vert = [-1 -2 -1; 
     0 0 0; 
     1 2 1]* 0.25; // vertical filter 

hor = [-1 0 1; 
     -2 0 2; 
     -1 0 1]* 0.25; // horizontal filter 

OutputV = conv2(G, vert); // applying the filter to the image 
OutputH = conv2(G, hor); 

它的工作很大。然后当我尝试将它们结合在一起时,我使用这个公式:

// sqrt((OutputV^2) + (OutputH^2)) 
Output = OutputV ^2; 
Output1 = OutputH ^2; 

Output2 = Output + Output1; 
Output3 = sqrt(Output2); 

我得到一个很奇怪的图像。任何建议

+2

不确定你到底在做什么,但是当你使用OutputV^2时,你实际上在做OutputV * OutputV,矩阵乘法。你可能想要做的是OutputV。^ 2,那是OutputV。* OutputV,标量积,在这种情况下,它将矩阵的每个元素 – Inox

+0

谢谢Inox,它现在可以工作,我将它改为。^ 2 – N4LN

回答

0

你应该使用“每像素”方操作:

Output = sqrt((OutputV .^ 2) + (OutputH .^ 2)); 

的你写的MATLAB执行的矩阵乘法(不是入境明智的操作)。