haar 特征计算

来源:互联网 发布:淘宝链接地址怎么弄 编辑:程序博客网 时间:2024/05/21 16:54


function haar = AdaBoost_haar(m, n)
% 在m*n检测窗口中遍历符合(s, t)条件矩形特征,包括(1, 2), (2, 1), (1, 3), (3, 1), (2, 2)
% 对20*20检测窗口而言,共有78460个符合上述矩形特征的haar结构
% m: 检测窗口列数
% n: 检测窗口行数
% haar(s, t, x_lu, y_lu, x_rd, y_rd)
% 参考《基于adaboost算法的人脸检测技术》(P.7)

N = 0;
haar = zeros(1,6);
for Num = 1:5
    switch Num
        case 1
            s=1; t=2; % (1, 2)矩形特征
        case 2
            s=2; t=1; % (2, 1)矩形特征
        case 3
            s=1; t=3; % (1, 3)矩形特征
        case 4
            s=3; t=1; % (3, 1)矩形特征
        case 5
            s=2; t=2; % (2, 2)矩形特征
    end   
    for x_lu = 1:m-s+1
        for y_lu = 1:n-t+1
            P = floor((m-x_lu+1)/s); % 向下取整
            Q = floor((n-y_lu+1)/t); % 向下取整
            for i = 1:P
                for j = 1:Q
                    N = N +1;
                    haar(N,:) = [s, t, x_lu, y_lu, x_lu+i*s-1, y_lu+j*t-1];
                end
            end
        end
    end
end

0 0
原创粉丝点击