用法同 openCV, 使用最小二乘迭代
function corners_tuned = refine_pos( src, corners) % corners: N*2
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
corners_tuned = corners;
% some parameters needed to set;
win.width = 3;
win.height = 3;
eps = 0.00001;
max_iters = 20;
count = size(corners, 1);
% parameters derived;
win_w = win.width*2 + 1;
win_h = win.width*2 + 1;
coeff = 1.0/(win.width*win.width);
maskX = zeros(win_w, 1, 'double');
maskY = zeros(win_h, 1, 'double');
mask = zeros(win_h, win_w, 'double');
for i = -win.width:1:win.width
maskX(i + win.width + 1) = exp(-i*i*coeff);
end
maskY = maskX;
for i = 1:1:win_w
for j = 1:1:win_h
mask(i, j) = maskX(j)*maskY(i);
end
end
for pt_i = 1:1:count
ct = corners(pt_i, :);
iter = 0;
err = 0.0;
nci.x = ct(1, 2);
nci.y = ct(1, 1);
str = sprintf('============== p%d iteration =============', pt_i);
disp(str);
while (1)
% s1: get the sub-pixsel data;
&

该函数用于在MATLAB中精炼图像角点的位置,采用最小二乘迭代方法提高角点检测的亚像素精度。代码首先定义了窗口大小、误差阈值和最大迭代次数,然后通过创建掩模矩阵并进行子像素数据采样、梯度计算及位置更新,不断迭代优化角点坐标,直至达到预设的精度标准。

356

被折叠的 条评论
为什么被折叠?



