取景器对准
有人使用过取景器对齐方法吗?第一步(边缘检测)或多或少是可以理解的。据说“为了提取边缘,我们在四个等距方向上取图像的平方梯度:水平、垂直和两个对角线方向。” (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]1、py[i]1、pu[i]1 和 pv[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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解该算法,px、py、pu 和 pv 是 4 个方向中每个方向的积分投影。因此,代码中的 px 是
pl
。 px[i]0 是该向量中的每个点 - 代码中的 pl(i) 。 px[i]1 是获取用于生成投影的总点数(归一化系数?)。因此所有 px[i]1 的总和将是图像高度h
。对于其他方向,类似。重复我对您的问题的评论,为了获得更好的性能,您应该尽量避免循环,特别是嵌套循环,特别是当它像您的情况一样简单时:
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 heighth
. 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: