运动估计作业-MATLAB仿真
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
运动是视频序列的一个主要特点之一运动估计技术是视频压缩领域中最重要、发展最快的技术之一,它是提高编码效率的主要途径。研究快速有效的运动估计算法一直是视频编码领域的热点问题
运动估计主程序
clear all
mbSize=16;
p=7;
filename='hao.yuv';
fp=fopen(filename,'r');
width=176;
height=144;
i=17;
fseek(fp,i* 1.5 *width*height,'bof');
bufI=fread(fp,width*height,'uchar');
imgI=double((reshape(bufI,width,height))');
imgI0=uint8((reshape(bufI,width,height))');
Figure1,imshow(imgI0);
title('第10帧');
imgI=double(imgI0);
fseek(fp,0.5*width*height,'cof');
bufP=fread(fp,width*height,'uchar');
imgP0=uint8((reshape(bufP,width,height))');
figure,imshow(imgP0);
title('第35帧');
imgP=double(imgP0);
将搜索中心定在搜索框的最左上角点。
搜索中心从左至右,从上至下移位,并计算每一个点,直到计算完搜索框内所有点。
比较所有计算的点,最小值点即为最佳匹配点。
全搜索法
[motionVect, computations] = motionEstES(b,a,blocksize,p);
imgComp = motionComp(a, motionVect, blocksize);
c=b-imgComp;
figure(2);
subplot(121);
imshow(uint8(imgComp));
title('全搜索法运动估计得到的第35帧');
subplot(122);
imshow(uint8(c));
title('与第35帧的误差');
ESpsnr = imgPSNR(b, imgComp, 255);
、
先以中心点为搜索中心,进行四周4点距离搜索,计算9个点,得到最小值点。
将搜索中心移至最小值点,进行四周2点距离搜索,计算9个点,得到最小值点。
将搜索中心移至最小值点,进行四周1点距离搜索,计算9个点,得到最小值点,此最小值点即为最终的搜索结果作为运动估计的最优匹配点。
三步法
[motionVect,computations ] = motionEstTSS(b, a, blocksize, p)
imgComp = motionComp(a, motionVect, blocksize);
c=b-imgComp;
figure(3);
subplot(121);
imshow(uint8(imgComp));
title('三步法运动估计得到的第35帧');
subplot(122);
imshow(uint8(c));
title('与第35帧的误差');
TSSpsnr = imgPSNR(b, imgComp, 255);
先以中心点为搜索中心,进行大钻石搜索,计算9个点。
如果9个点的最小值点不在大钻石的中心,则将大钻石的中心移至该点,重复大钻石搜索,直到最小值点处于大钻石中心为止。
在大钻石的中心点切换到小钻石搜索模式,共搜索5个点,其中值最小的点即为最终的搜索结果作为运动估计的最优匹配点。
四步法
[motionVect,computations ] = motionEst4SS(b, a, blocksize, p)
toc
imgComp = motionComp(a, motionVect, blocksize);
c=b-imgComp;
figure(4);
subplot(121);
imshow(uint8(imgComp));
title('四步法运动估计得到的第35帧');
imshow(uint8(c));
title('与第35帧的误差');
SS4psnr = imgPSNR(b, imgComp, 255);
钻石法
[motionVect,computations ] = motionEstDS(b, a, blocksize, p) toc
imgComp = motionComp(a, motionVect, blocksize);
c=b-imgComp;
figure(5);
imshow(uint8(imgComp));
title('钻石法运动估计得到的第35帧');
subplot(122);
imshow(uint8(c));
title('与第35帧的误差');
DSpsnr = imgPSNR(b, imgComp, 255);
(注:可编辑下载,若有不当之处,请指正,谢谢!)