您的位置:首页 > 其它

haar 特征计算

2015-09-15 21:26 309 查看

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: