混合高斯模型运动目标检测matlab代码.docx
- 文档编号:29793727
- 上传时间:2023-07-27
- 格式:DOCX
- 页数:9
- 大小:15.68KB
混合高斯模型运动目标检测matlab代码.docx
《混合高斯模型运动目标检测matlab代码.docx》由会员分享,可在线阅读,更多相关《混合高斯模型运动目标检测matlab代码.docx(9页珍藏版)》请在冰豆网上搜索。
混合高斯模型运动目标检测matlab代码
functionvarargout=TT1(varargin)
%TT1M-fileforTT1.fig
%TT1,byitself,createsanewTT1orraisestheexisting
%singleton*.
%
%H=TT1returnsthehandletoanewTT1orthehandleto
%theexistingsingleton*.
%
%TT1('CALLBACK',hObject,eventData,handles,...)callsthelocal
%functionnamedCALLBACKinTT1.Mwiththegiveninputarguments.
%
%TT1('Property','Value',...)createsanewTT1orraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforeTT1_OpeningFunctiongetscalled.An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.AllinputsarepassedtoTT1_OpeningFcnviavarargin.
%
%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone
%instancetorun(singleton)".
%
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%Copyright2002-2003TheMathWorks,Inc.
%EdittheabovetexttomodifytheresponsetohelpTT1
%LastModifiedbyGUIDEv2.515-May-201421:
15:
36
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@TT1_OpeningFcn,...
'gui_OutputFcn',@TT1_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
ifnargin&&ischar(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%Endinitializationcode-DONOTEDIT
%---ExecutesjustbeforeTT1ismadevisible.
functionTT1_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstoTT1(seeVARARGIN)
%ChoosedefaultcommandlineoutputforTT1
handles.output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesTT1waitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=TT1_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%==========================================================================
functionpushbutton1_Callback(hObject,eventdata,handles)
B0=double((imread('a1.bmp')));
[m,n]=size(B0);
t=20;
M=fix(m/t);
N=fix(n/t);
B=zeros(m,n,3);
B(:
:
1)=B0;
T=10;
a=0.01;
Flag=0;
Gk=zeros(m,n,3);%高斯权值
Gk(:
:
1)=ones(m,n);
b=0.005;
k1=1;
fork=1:
5:
659
c=num2str(k,'%d');
c=strcat('a',c);
c=strcat(c,'.bmp');
I=double((imread(c)));
axes(handles.axes1);
imshow(uint8(I));
axes(handles.axes2);
imshow(uint8(B0));
axes(handles.axes3);
imshow(uint8(abs(I-B0)));
%s=0;
%fori1=1:
M
%forj1=1:
N
%I1=I(t*(i1-1)+1:
t*i1,t*(j1-1)+1:
t*j1);
%B01=B0(t*(i1-1)+1:
t*i1,t*(j1-1)+1:
t*j1);
%d=abs(sum(sum(I1))-sum(sum(B01)))/(t*t);
%ifd>15
%s=s+1;
%end
%end
%end
%ifs>(M*N)/2
%B0=I;
%k1=1;
%B=zeros(m,n,3);
%B(:
:
1)=B0;
%continue;
%end
b=1/(k1+1)+0.005;
k1=k1+1;
fori=1:
m
forj=1:
n
Flag=0;
forp=1:
3
ifabs(I(i,j)-B(i,j,p)) B(i,j,p)=(1-a)*B(i,j,p)+a*I(i,j); Flag=1; x1=p+1; x2=p+2; ifx1>3 x1=x1-3; end ifx2>3 x2=x2-3; end a1=Gk(i,j,x1); a2=Gk(i,j,x2); ifa1+a2>0 Gk(i,j,p)=Gk(i,j,p)+b; ifGk(i,j,p)>1 Gk(i,j,p)=1; end Gk(i,j,x1)=a1-(a1/(a1+a2))*b; Gk(i,j,x2)=a2-(a2/(a1+a2))*b; ifGk(i,j,x1)<0 Gk(i,j,x1)=0; end ifGk(i,j,x2)<0 Gk(i,j,x2)=0; end end Flag=1; break; end end ifFlag==1 Max=-1; forq=1: 3 ifMax Max=Gk(i,j,q); Max_k=q; end B0(i,j)=B(i,j,Max_k); end else Min=1000; forq=1: 3 ifMin>Gk(i,j,q) Min=Gk(i,j,q); Min_k=q; end end B(i,j,Min_k)=I(i,j); p=Min_k; x1=p+1; x2=p+2; ifx1>3 x1=x1-3; end ifx2>3 x2=x2-3; end a1=Gk(i,j,x1); a2=Gk(i,j,x2); ifa1+a2>0 Gk(i,j,p)=Gk(i,j,p)+b; ifGk(i,j,p)>1 Gk(i,j,p)=1; end Gk(i,j,x1)=a1-(a1/(a1+a2))*b; Gk(i,j,x2)=a2-(a2/(a1+a2))*b; ifGk(i,j,x1)<0 Gk(i,j,x1)=0; end ifGk(i,j,x2)<0 Gk(i,j,x2)=0; end end end end end end
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 混合 模型 运动 目标 检测 matlab 代码