% d=PyramidalLKOpticalFlow(img1, img2, roi)
%
% Computes the Lucas-Kanade optical flow using a gaussian pyramid.
% The function builds a pyramid for images 1 and 2 and computes the flow
% in each level, and using the flow an lower levels as initial estimates
% for the flow in higher levels. The flow is computed as the displacement
% from img2 to img1.
%
% Inputs:
% img1 - The source image.
% img2 - The destination image.
% roi - A region in img1 in which the flow should be computed.
%
% Outpus:
% d - The computed affine transformation parameters
function d=PyramidalLKOpticalFlow(img1, img2, roi)
img1=double(img1);
img2=double(img2);
roiSize = 1+roi(3:4)-roi(1:2);
% Compute boundry for number of levels. We define two bounds. K<=6. In most
% cases more than 6 levels is not needed => the image becomes too small.
% Also, the roi at level k should not be too small. We define here that roi
% should not become less than 4x4 pixels.
%
% Since the size of the ROI at level k is Roiwidth/2^k we have
% Roiwidth/2^k >= 4 => 2^k<=Roiwidth/4 => k<log2(Roiwidth/4) =
% log2(Roiwidth)-2
levels = min([floor(log2(min(roiSize))-2), 6]);
% Compute Pyramids for image 1 and 2
pyramid1 = GuassianPyramid(img1, levels);
pyramid2 = GuassianPyramid(img2, levels);
% Set d to an empty affine displacement transformation
d=zeros(2,3);
% Start with initial translation 0 at lowest pyramid
for l=levels:-1:1
disp(sprintf('Computing optical flow at level %u', l));
% Transform displacement to current level
d(:,3)=sum(d,2)+d(:,3);
% Compute current location of ROI
tl=ceil(roi(1:2)./2^(l-1));
% Compute current size of ROI
sz=floor(roiSize./2^(l-1));
% Make sure origin is at least 2
tl=max(tl, [2 2]);
br=min(tl+sz-1, size(pyramid1{l})-1);
% Compute displacement at current level
d=IterativeLKOpticalFlow(pyramid1{l}, pyramid2{l}, [tl br], d);
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
Tikhonov正则化超分辨率重建.7z (21个子文件)
disk.mat 71KB
DTDZ.m 273B
text.mat 82KB
WTWZ.m 740B
LKOFlow
Affine
GuassianPyramid.m 812B
IterativeLKOpticalFlow.m 2KB
RegisterImageSeq.m 914B
GaussianDownSample.m 768B
ResampleImg.m 463B
ComputeLKFlowParms.m 986B
PyramidalLKOpticalFlow.m 2KB
GuassianPyramid.m 812B
IterativeLKOpticalFlow.m 1KB
RegisterImageSeq.m 418B
GaussianDownSample.m 768B
ResampleImg.m 282B
ComputeLKFlowParms.m 780B
PyramidalLKOpticalFlow.m 2KB
WTY.m 425B
SuperRes.m 634B
test.m 994B
共 21 条
- 1
旅途中的宽~
- 粉丝: 7w+
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- web期末大作业-HTML+CSS+JS仿王者荣耀官网网站HTML5项目实训源码.zip
- 帕鲁ppt备份只是为了方便
- 3.15 设计vi,产生一个0.0到10.0的随机数,与10.0相乘,然后通过一个字vi将积与100相加后开方
- 3.14 设计vi,比较两个数,如果其中一个数大于另一个数,则点亮LED指示灯
- 08最短路径_Floyd.c
- 02二叉排序树_BinarySortTree.c
- python字符串逆序方法.md
- qt软件开发+代码+注释+自我学习+windows软件开发+图像分割
- python二叉树的遍历.md
- 1cdd0859202f67f8bf6945fd9559ea102d27d11b
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0