【问题标题】:Edge magnitude (Vertical and horizontal edges)边缘幅度(垂直和水平边缘)
【发布时间】:2014-06-03 05:14:37
【问题描述】:

我想将垂直和水平边缘连接在一起以获得图像中的所有边缘,以便将其用于哈里斯角检测。

我正在使用 Sobel 过滤器来获取垂直和水平边缘:

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

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

【问题讨论】:

  • 不确定你到底在做什么,但是当你使用OutputV^2时,你实际上是在做OutputV*OutputV,矩阵乘法。您可能想要做的是 OutputV.^2,它是 OutputV.*OutputV,标量积,在这种情况下,它将平方矩阵的每个元素
  • 感谢 Inox,现在可以使用了,我将其更改为 .^2

标签: matlab image-processing edge-detection


【解决方案1】:

您应该通过以下方式使用“每像素”平方运算:

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

您编写的 MATLAB 执行矩阵乘法(而不是逐项操作)。

【讨论】: