optical_flow.rar

• cryingforever
了解作者
• matlab
开发工具
• 1KB
文件大小
• rar
文件格式
• 0
收藏次数
• 1 积分
下载积分
• 124
下载次数
• 2010-04-16 21:17
上传日期

optical_flow.rar
• optical_flow
• optical_flow.m
2.4KB

function [us,vs] = HSoptflow(Xrgb,n) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Author: Gregory Power gregory.power@wpafb.af.mil % This MATLAB code shows a Motion Estimation map created by % using a Horn and Schunck motion estimation technique on two % consecutive frames. Input requires. % Xrgb(h,w,d,N) where X is a frame sequence of a certain % height(h), width (w), depth (d=3 for color), % and number of frames (N). % n= is the starting frame number which is less than N % V= the output variable which is a 2D velocity array % % Sample Call: V=HSoptflow(X,3); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% [h,w,d,N]=size(Xrgb) if n>N-1 error(1,'requested file greater than frame number required'); end; %get two image frames if d==1 Xn=double(Xrgb(:,:,1,n)); Xnp1=double(Xrgb(:,:,1,n+1)); elseif d==3 Xn=double(Xrgb(:,:,1,n)*0.299+Xrgb(:,:,2,n)*0.587+Xrgb(:,:,3,n)*0.114); Xnp1=double(Xrgb(:,:,1,n+1)*0.299+Xrgb(:,:,2,n+1)*0.587+Xrgb(:,:,3,n+1)*0.114); else error(2,'not an RGB or Monochrome image file'); end; %get image size and adjust for border size(Xn) hm5=h-5; wm5=w-5; z=zeros(h,w); v1=z; v2=z; %initialize dsx2=v1; dsx1=v1; dst=v1; alpha2=625; imax=20; %Calculate gradients dst(5:hm5,5:wm5) = ( Xnp1(6:hm5+1,6:wm5+1)-Xn(6:hm5+1,6:wm5+1) + Xnp1(6:hm5+1,5:wm5)-Xn(6:hm5+1,5:wm5)+ Xnp1(5:hm5,6:wm5+1)-Xn(5:hm5,6:wm5+1) +Xnp1(5:hm5,5:wm5)-Xn(5:hm5,5:wm5))/4; dsx2(5:hm5,5:wm5) = ( Xnp1(6:hm5+1,6:wm5+1)-Xnp1(5:hm5,6:wm5+1) + Xnp1(6:hm5+1,5:wm5)-Xnp1(5:hm5,5:wm5)+ Xn(6:hm5+1,6:wm5+1)-Xn(5:hm5,6:wm5+1) +Xn(6:hm5+1,5:wm5)-Xn(5:hm5,5:wm5))/4; dsx1(5:hm5,5:wm5) = ( Xnp1(6:hm5+1,6:wm5+1)-Xnp1(6:hm5+1,5:wm5) + Xnp1(5:hm5,6:wm5+1)-Xnp1(5:hm5,5:wm5)+ Xn(6:hm5+1,6:wm5+1)-Xn(6:hm5+1,5:wm5) +Xn(5:hm5,6:wm5+1)-Xn(5:hm5,5:wm5))/4; for i=1:imax delta=(dsx1.*v1+dsx2.*v2+dst)./(alpha2+dsx1.^2+dsx2.^2); v1=v1-dsx1.*delta; v2=v2-dsx2.*delta; end; u=z; u(5:hm5,5:wm5)=v1(5:hm5,5:wm5); v=z; v(5:hm5,5:wm5)=v2(5:hm5,5:wm5); xskip=round(h/32); [hs,ws]=size(u(1:xskip:h,1:xskip:w)) us=zeros(hs,ws); vs=us; N=xskip^2; for i=1:hs-1 for j=1:ws-1 hk=i*xskip-xskip+1; hl=i*xskip; wk=j*xskip-xskip+1; wl=j*xskip; us(i,j)=sum(sum(u(hk:hl,wk:wl)))/N; vs(i,j)=sum(sum(v(hk:hl,wk:wl)))/N; end; end; figure(1); quiver(us,vs); colormap('default'); axis ij; axis tight; axis equal;

相关推荐
• optical-flow-method.zip
• OpenCV_Demo.rar
利用opencv3实现光流法追踪运动目标
• Optical-flow-method.rar
光流是一种简单实用的图像运动的表达方式[1] ，通常定义为一个图像序列中的图像亮度模式的表观运动，即空间物体表面上的点的运动速度在视觉传感器的成像平面上的表达。这种定义认为光流只表示一种几何变化。1998年...
• optical-flow.rar
Motion detection based on optical flow target
• 光流法运动检测代码C++，opencv
运用光流法检测运动的C++代码，调用了opencv，读取摄像头或视频，检测视频中的运动，并显示运动的大小和方向
• optical flow.zip
配准可以分为刚性、非刚性的配准，通常经过刚性配准之后，例如尺度旋转不变性（SIFT）算法、加速鲁棒性算法（SURF）进行配准之后，细微形变仍然没有解决，通过光流场模拟全局形变之后，根据变形场复合得到配准之后的...
• 光流目标检测
光流法对视频运动目标进行检测，检测效果不错
• 光流法进行运动目标检测
这个代码可以直接使用。打开，下载，然后可以替换自己的视频文件就可以正常运行了。
• LK光流算法文档
LK光流算法，可以实现视频或者图片的跟踪，并且可以对LK算法的理解有很大的帮助
• matlabcnhelp.rar
matlab中文帮助很难找的，快速下载