MATLAB 亚像素点检测代码;

用法同 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;
   

你可能感兴趣的:(个人学习)