资源简介

阴影去除,用于视频监控中的运动目标检测后提取运动目标

资源截图

代码片段和文件信息


clear all
source = mmreader(‘highwayI_raw.AVI‘);

width = source.width;
height = source.height;
frames=source.NumberOfframes;
fr1 =  read(source1); 
fr1_bw = rgb2gray(fr1); 


V = zeros(heightwidth);              
M = zeros(heightwidth);         
D = zeros(heightwidth);           
t = zeros(heightwidth);   
SB = zeros(heightwidth);
SC = zeros(heightwidth);
SBC = zeros(heightwidth);
ER = zeros(heightwidth);
EB = zeros(heightwidth);
ET = zeros(heightwidth);
FNCC = zeros(heightwidth);
sum=0;  
L=5;
V=abs(double(fr1_bw)-double(fr1_bw));

for m = 1:100
     frm =  read(sourcem);      % read in frame
    fr_bwm= rgb2gray(frm); 
    sum = sum+double(fr_bwm);    
end
M=sum/100;
for n = 1:frames
      tic;
      t1=clock;
    fr =  read(sourcen);      % read in frame
    fr_bw = rgb2gray(fr);
%      fr_bw=medfilt2( fr_bw);
    t(::)=abs(double(M)-double(fr_bw));
      
    for i=1:height
        for j=1:width    
                V(ij)=V(ij)+sign(10+4*t(ij)-V(ij));
            
            if t(ij)                 D(ij)=0;  
                  M(ij)=double(M(ij))+sign((double(fr_bw(ij))-double(M(ij))));
            else
                 D(ij)=1;
            end
              
        end
    end
              
 
            
%******************************
  
      D = medfilt2(D);
     D=bwmorph(D‘close‘);  
    D = bwfill(D‘holes‘);
   for i=2+L:height-L
        for j=2+L:width-L  
            if D(ij)==1 
           SB(ij) = sqrt(double(M(ij))^2+SB(ij-1)^2+SB(i-1j)^2-SB(i-1j-1)^2);
           SC(ij) = sqrt(double(fr_bw(ij))^2+SC(ij-1)^2+SC(i-1j)^2-SC(i-1j-1)^2);
           SBC(ij) = double(M(ij)*fr_bw(ij))+SBC(ij-1)+SBC(i-1j)-SBC(i-1j-1);
           ER(ij)=(SC(i+Lj+L))-(SC(i-L-1j+L))-(SC(i+Lj-L-1))+(SC(i-L-1j-L-1));
           EB(ij)=SB(i+Lj+L)^2-SB(i-L-1j+L)^2-SB(i+Lj-L-1)^2+SB(i-L-1j-L-1)^2;
           ET(ij)=(SC(i+Lj+L)^2-SC(i-L-1j+L)^2-SC(i+Lj-L-1)^2+SC(i-L-1j-L-1)^2);
           FNCC(ij)=ER(ij)^2/(EB(ij)*ET(ij));
           if  FNCC(ij)<1 && EB(ij)>ET(ij)
               D(ij)=0;
           end
            end
        end
   end
  
%       [Lnum]=bwlabel (D8);
%    
%       for  nn=1:num        
%               [xy]=find(L==nn);                    %找到被标记的目标坐标

%               Xmin=min(min(x));                    
%               Xmax=max(max(x));                    %计算目标对角线两顶点的坐标 
%               Ymin=min(min(y));                    %(Xmin,Ymin)和(Xmax,Ymax)
%               Ymax=max(max(y));

%                 if (Xmin>10)&(Xmax<200);             %当车全部出现时画框
%  
%                        L(XminYmin:Ymax)=1;        %在二值图象上利用两点坐标确定矩形框
%                        L(XmaxYmin:Ymax)=1;
%                        L(Xmin:XmaxYmin)=1;
%                        L(Xmin:XmaxYmax)=1;
%  
%                        D(XminYmin:Ymax)=1;   %将框的位置映射到归一化的差分图象
%                        D(XmaxYmin:Ym

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        4999  2012-04-17 19:33  shadow.m

评论

共有 条评论