本文介绍了实现 Harris 角点检测器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实施一个 Harris 角检测器以用于教育目的,但我卡在了 harris 响应部分.基本上,我正在做的是:

I am implementing a Harris corner detector for educational purposes but I'm stuck at the harris response part. Basically, what I am doing, is:

  1. 计算 x 和 y 方向的图像强度梯度
  2. (1) 的模糊输出
  3. 根据 (2) 的输出计算 Harris 响应
  4. 在 3x3 邻域和阈值输出中抑制 (3) 的输出中的非最大值

1 和 2 似乎工作正常;但是,作为 Harris 响应,我得到的值非常小,并且没有任何点达到阈值.输入是标准的户外摄影.

1 and 2 seem to work fine; however, I get very small values as the Harris response, and no point does reach the threshold. Input is a standard outdoor photography.

[...]
[Ix, Iy] = intensityGradients(img);
g = fspecial('gaussian');
Ix = imfilter(Ix, g);
Iy = imfilter(Iy, g);
H = harrisResponse(Ix, Iy);
[...]

function K = harrisResponse(Ix, Iy)
    max = 0;
    [sy, sx] = size(Ix);
    K = zeros(sy, sx);
    for i = 1:sx,
        for j = 1:sy,
            H = [Ix(j,i) * Ix(j,i), Ix(j,i) * Iy(j,i)
                Ix(j,i) * Iy(j,i), Iy(j,i) * Iy(j,i)];
            K(j,i) = det(H) / trace(H);
            if K(j,i) > max,
                max = K(j,i);
            end
        end
    end
    max
end

对于示例图片,max 最终为 6.4163e-018,这似乎太低了.

For the sample picture, max ends up being 6.4163e-018 which seems far too low.

推荐答案

Harris角点检测中的角点定义为区域内的最高值像素"(通常是3X35x5) 所以你关于没有达到阈值"的评论对我来说似乎很奇怪.只需收集所有像素值高于其周围 5x5 邻域中的所有其他像素的所有像素.

A corner in Harris corner detection is defined as "the highest value pixel in a region" (usually 3X3 or 5x5) so your comment about no point reaching a "threshold" seems strange to me. Just collect all pixels that have a higher value than all other pixels in the 5x5 neighborhood around them.

除此之外:我不是 100% 确定,但我认为你应该有:

Apart from that:I'm not 100% sure, but I think you should have:

K(j,i) = det(H) - lambda*(trace(H)^2)其中 lambda 是适用于您的情况的正常数(Harris 建议值为 0.04).

K(j,i) = det(H) - lambda*(trace(H)^2)Where lambda is a positive constant that works in your case (and Harris suggested value is 0.04).

一般来说,过滤您的输入的唯一合理时刻是在此之前:

In general the only sensible moment to filter your input is before this point:

[Ix, Iy] = intensityGradients(img);

过滤 Ix2Iy2Ixy 对我来说没有多大意义.

Filtering Ix2, Iy2 and Ixy doesn't make much sense to me.

此外,我认为您的示例代码在这里是错误的(函数 harrisResponse 是否有两个或三个输入变量?):

Further, I think your sample code is wrong here (does function harrisResponse have two or three input variables?):

H = harrisResponse(Ix2, Ixy, Iy2);
[...]

function K = harrisResponse(Ix, Iy)

这篇关于实现 Harris 角点检测器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 22:14