取景器对准

发布于 2024-12-21 14:04:13 字数 714 浏览 3 评论 0原文

有人使用过取景器对齐方法吗?第一步(边缘检测)或多或少是可以理解的。据说“为了提取边缘,我们在四个等距方向上取图像的平方梯度:水平、垂直和两个对角线方向。” (1)。 “然后我们在垂直于梯度方向的方向上对每个梯度图像执行积分投影” (2)。对于水平方向,我以这种方式实现该算法:

function pl = horgrad(a)
[h,w] = size(a);
b = uint8(zeros(h,w));
for i = 1 : h
        for j = 2 : w
                % abs() instead of squaring
                b(i,j) = abs(a(i,j) - a(i,j-1));     % (1)
        end
end
pl = sum(b);     % (2)

对我来说真正的问题是第二步:边缘对齐px[i]1py[i]1pu[i]1pv[i]1< 是什么意思/em>?为什么它们等于1? i-计数器如何变化?

Is there anyone who worked with Viewfinder Alignment method? The first step (Edge Detection) is more or less understandable. It's written that "to extract edges we take the squared gradient of the image in four equally spaced directions: horizontal, vertical, and the two diagonal directions." (1). And "we then perform an integral projection of each gradient image in the direction perpendicular to the direction of the gradient" (2). For horizontal direction I implemented that algorithm this way:

function pl = horgrad(a)
[h,w] = size(a);
b = uint8(zeros(h,w));
for i = 1 : h
        for j = 2 : w
                % abs() instead of squaring
                b(i,j) = abs(a(i,j) - a(i,j-1));     % (1)
        end
end
pl = sum(b);     % (2)

The real problem for me is the second step: Edge Alignment. What mean px[i]1, py[i]1, pu[i]1 and pv[i]1? Why are they equal to 1? How does i-counter change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苦笑流年记忆 2024-12-28 14:04:13

据我了解该算法,pxpypupv 是 4 个方向中每个方向的积分投影。因此,代码中的 pxpl。 px[i]0 是该向量中的每个点 - 代码中的 pl(i) 。 px[i]1 是获取用于生成投影的总点数(归一化系数?)。因此所有 px[i]1 的总和将是图像高度 h。对于其他方向,类似。

重复我对您的问题的评论,为了获得更好的性能,您应该尽量避免循环,特别是嵌套循环,特别是当它像您的情况一样简单时:

b(:,2:end)=abs(diff(a,1,2));

As I understand the algorithm, px, py, pu and pv are integral projections into each of 4 directions. So, px is pl in your code. px[i]0 is every point in this vector - pl(i) in the code. px[i]1 is to get total number of points used to generate the projection (normalization coefficient?). So the sum of all px[i]1 will be the image height h. For other direction it's similar.

Repeating my comment to your question, for better performance you should try to avoid loops, specially nested loops, specially when it is as easy as in your case:

b(:,2:end)=abs(diff(a,1,2));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文