运动估计算法实现

上传人:cl****1 文档编号:510353593 上传时间:2022-12-22 格式:DOCX 页数:15 大小:156.83KB
返回 下载 相关 举报
运动估计算法实现_第1页
第1页 / 共15页
运动估计算法实现_第2页
第2页 / 共15页
运动估计算法实现_第3页
第3页 / 共15页
运动估计算法实现_第4页
第4页 / 共15页
运动估计算法实现_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《运动估计算法实现》由会员分享,可在线阅读,更多相关《运动估计算法实现(15页珍藏版)》请在金锄头文库上搜索。

1、运动估计算法实现一、实验目的:1、掌握运动估计算法的实现原理。在视频编码和处理系统中,运动估计和运动补偿技术对降低视频 序列时间冗余度、提高编码效率起着非常关键的作用。运动估计的准 确程度将直接决定视频编码器的编码效率。它极大地消除了视频序列 的帧间相关性。运动估计算法的复杂性将直接决定视频压缩编码系统 的复杂性,如何提高运动估计的效率,使运动估计算法的搜索过程更 快速、更高效一直是人们研究的热点。掌握运动估计的块匹配算法, 以及快速运动估计算法。2、掌握运动估计算法的研究现状及多种计算方法。3、学习基于块的全搜索运动估计算法,研究分析其 Matlab 实现 程序过程,并补充完成程序,对实验结

2、果进行分析比较。二、实验内容1、分析基于块匹配的全搜索运动估计算法程序,画出mo tionEs tAnalysis.m 文件流程图开贻2、编程补充完成costFuncMAD.m文件中最小绝对误差计算函数costFuncMAD ()和imgPSNR.m文件中峰值信噪比PSNR计算函数 imgPSNR ()的程序,最终输出运动矢量场;3、掌握运动补偿算法,编程补充minCos t()函数;4、了解多种快速运动估计算法,例如三步法搜索法、菱形搜索法等。 总结实验结果。三、实验原理在帧间预测编码中,由于活动图像邻近帧中的景物存在着一定的 相关性。因此,可将活动图像分成若干块或宏块,并设法搜索出每个 块

3、或宏块在邻近帧图像中的位置,并得出两者之间的空间位置的相对 偏移量,得到的相对偏移量就是通常所指的运动矢量,得到运动矢量 的过程被称为运动估计。运动矢量和经过运动匹配后得到的预测误差共同发送到解码端, 在解码端按照运动矢量指明的位置,从已经解码的邻近参考帧图像中 找到相应的块或宏块,和预测误差相加后就得到了块或宏块在当前帧 中的位置。运动估计的准确程度往往用补偿图像与原图像比较的PSNR来 衡量表示。四、实验要求1、对实验程序 motionEstAnalysis.m 进行分析,完成主程序流程图。函数流程图:2、编写补充完成部分不全程序代码,调试程序使其能正确运行(1) motionEstAna

4、lysis.m% This script uses all the Motion Estimation algorithms written for the% final project and save their results.close allclear all% imageName = caltrain.avi; p = 7; imgP1=double(imread(imagP.bmp); imgI1=double(imread(imagI.bmp); imgP=imgP1(:,:,1);imgI=imgI1(:,:,1);row col = size(imgI);% Exhaust

5、ive Search%uOUeepAEENEEaBlockCenter, motionVect, computations = motionEstES(imgP,imgI,mbSize,p);% P Oj卩 imgPComp = motionComp(imgI, motionVect, mbSize);% p 0:卩土Oi卩cO0ii(Tf這卩ApsnrO卩%ESpsnr(i+1) = imgPSNR(imgP,imgPComp,255); n=255;PsNR=imgPsNR(imgP,imgPComp,255) %MSE=(1/(n*n)*sum(sum(imgP-imgPComp).A2

6、);%PSNR=10*log(max(max(imgPComp).A2/MSE);%psnr=PsNR;%EScomputations(i+1) = computations;% p Oj卩 imagePDiff = imgP - imgPComp;figure;imageI = uint8(imgI);imageP = uint8(imgP);imagePComp = uint8(imgPComp);imagePDiff = uint8(imagePDiff);subplot(221);imshow(imageI);title(I 0:2(厶吻(吻了這);subplot(222);imsho

7、w(imageP);title(P Oj卩士subplot(223);imshow(imagePComp);title(P Oj卩0011(吻了這);subplot(224);imshow(imagePDiff);title(P Oj卩GO0iif62iiTYn);% 0总总,瓦吻figure;quiver( BlockCenter(2,:), BlockCenter(1,:), motionVect(2,:), motionVect(1,:), .2,r);axis(0 320 0 240);for i=mbSize:mbSize:col-mbSizei,i;y = 0,row;line(x

8、,y,LineStyle,-,Marker,none);endforj=mbSize:mbSize:row-mbSizex =0,col;y = j,j; line(x,y,LineStyle,-,Marker,none); endxlabel(X);ylabel(Y);(2) motionEstES( )% Comp utes motion vec tors using exhaus tive search met hod(全搜索法计算 运动矢量)% Input% imgP : The image for which we want to find motion vectors (当前图 像

9、)% imgl : The reference image (参考图像)% mbSize : Size of the macroblock (宏块尺寸)% p : Search parameter (read literature to find what this means)搜 索参数)% Ouput% motionVect : the motion vectors for each integral macroblock in imgP (当前图像中每一个积分宏块的运动矢量)% EScomputations: The average number of points searched f

10、or a macroblock (每个宏块搜索的平均点数)% Written by Aroh Barjatya function BlockCenter, motionVect, EScomputations = motionEstES(imgP,imgl, mbSize, p) % 定义函数文件motionEstES.m, imgP、imgl、mbSize、p 为传入参数,BlockCe nt er、motio nVec t、EScomp utations为返回参数row col = size(imgl);%将参考图像的行数赋值给row,列数赋值给colblockcenter = zeros

11、(2,row*col/mbSize2);vectors = zeros(2,row*col/mbSize2); % 定义全0的矢量矩阵的大小 costs = ones(2*p + 1, 2*p +1) * 65537;% 定义最小绝对差矩阵的大小computations = 0;% 搜索点数赋初值为0% we st art off from the top left of the image (从图像左上角开始)% we will walk in steps of mbSize (以宏块尺寸为步长)% for every marcoblock that we look at we will l

12、ook for% a close match p pixels on the left, right, top and bottom of it (对 于每一个宏块,在它的上下左右找到与搜索参数p最匹配的像素)mbCount = 1;%搜索的宏块数赋初值为1%1为循环起始值,mbSize为步长值,row-mbSize+1为循环终止值for i = 1 : mbSize : row-mbSize+1for j = 1 : mbSize : col-mbSize+1% the exhaustive search starts here (全搜索开始)% we will evaluate cost

13、for (2p + 1) blocks vertically% and (2p + 1) blocks horizon tal(我们将计算水平方向上(2p + 1) 个块的最小绝对差和垂直方向上(2p + 1)个块的最小绝对差)% m is row(vertical) index (m为行扌旨数)% n is col(horizo nt al) index (n为列扌旨数)% this means we are scanning in raster orderfor m = -p :p%水平方向上位移矢量范围for n = -p :p%垂直方向上位移矢量范围% row/Vert co-ordi

14、nate for ref block (参考块的行(垂直方向)的范围)refBlkVer =i+m;% col/Horizontal co-ordinate (参考块的列(水平方向)的范 围)refBlkHor = j+n;%如果参考块的行列范围的任意一个在已经搜索过的宏块之 外,则继续下一步的搜索if ( refBlkVer row .| refBlkHor col) continue;endcosts(m+p+1,n+p+1) = costFuncMAD(imgP(i:i+mbSize-1,j:j+mbSize-1), .imgI(refBlkVer:refBlkVer+mbSize-1,

15、 refBlkHor:refBlkHor+mbSize-1), mbSize);% 搜索下一个点computations = computations + 1;endend% Now we find the vector where the cost is minimum% and store it . this is what will be passed back.(现在找到 有最小绝对差的矢量并存储它,这就是将被返回的东西)%blockcenter(1,mbCount) = i+ mbSize/2-1;blockcenter(2,mbCount) = j+ mbSize/2-1;% finds which macroblock in imgl gave us min Cost (找到参考图 像中最小绝对差的宏块)dx, dy, min

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号