• 大小: 2KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-06
  • 语言: Matlab
  • 标签: matlab  

资源简介

本文档仅仅是一个提取HAAR特征的过程,没有加入adaboost训练器,有需要的可以下载仿真一下。仅供参考,不作科研使用

资源截图

代码片段和文件信息

% 提取Harr-like特征 
% II           积分图像
% HarrLike     类Harr模板
% baseSize     基准的尺寸大小 

function [FeatureVector]=extHarrLikeFeature(IIHarrLikebaseSize)
imgWidth=size(II1);
imgHeight=size(II2);

wdiv=2;                  % 横向间隔
hdiv=2;                  % 纵向间隔

PreLen=ceil(imgWidth/wdiv)*ceil(imgHeight/hdiv)*length(HarrLike)*length(baseSize);
featureVector=zeros(PreLen1);

rect=zeros(14);         % 矩形四个顶点的积分值 
exBoud=zeros(12);       % 是否越界的标志
cnt=1;

for i=1:wdiv:imgWidth                     % 当前横坐标
    for j=1:hdiv:imgHeight                % 当前纵坐标
        for k=1:length(baseSize)          % 当前窗口基准大小
            for harrCnt=1:length(HarrLike)% 当前采取的Harr-like形式
                % 检查边界
                exBoud(1)=(i+size(HarrLike{harrCnt}1)*baseSize(k)>imgWidth);
                exBoud(2)=(j+size(HarrLike{harrCnt}2)*baseSize(k)>imgHeight);
                if(exBoud(1)+exBoud(2)>=1)
                    continue;
                end
                curFeabase=zeros(size(HarrLike{harrCnt}));
                for xx=1:size(HarrLike{harrCnt}1)
                    for yy=1:size(HarrLike{harrCnt}2)   % 获得每个矩形的四个顶点值
                        rect(1)=II(i+(xx-1)*baseSize(k)j+(yy-1)*baseSize(k));
                        rect(2)=II(i+(xx-1)*baseSize(k)j+(yy)*baseSize(k));
                        rect(3)=II(i+(xx)*baseSize(k)j+(yy-1)*baseSize(k));
                        rect(4)=II(i+(xx)*baseSize(k)j+(yy)*baseSize(k));
                        curFeabase(xxyy)=HarrLike{harrCnt}(xxyy)*...
                            ((rect(4)+rect(1)-rect(2)-rect(3)));
                    end
                end
                FeatureVector(cnt)=sum(sum(curFeabase));
                cnt=cnt+1;
            end
        end
    end
end
FeatureVector=FeatureVector(1:cnt-1);


    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1919  2007-10-26 20:01  haar feature extract\extHarrLikeFeature.m

     文件        318  2007-06-29 10:39  haar feature extract\IntegralImage.m

     文件       3120  2016-03-04 18:01  haar feature extract\testHarrLikeFea.m

     目录          0  2016-03-04 19:38  haar feature extract

----------- ---------  ---------- -----  ----

                 5357                    4


评论

共有 条评论