⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macromotionsearch.m

📁 用matlab写的仿真H.263标准的程序
💻 M
字号:
function [VectorRow,VectorCol] = MacroMotionSearch(MarcoBlock,Windows,WHeight,WWidth)
%在指定窗口内进行全搜索
%输入 MacroBlock ,目标16x16亮度宏块,uint8
%输入 Windows,搜索窗口,uint8
%输入 WHeight,WWidth,搜索窗口高和宽
%输出 VectorRow,VectroCol 运动矢量;与中心窗口的偏移量
sad = 9999999;
vh = 0;
vw = 0;
for i = 1:(WHeight - 15)
    for j = 1:(WWidth - 15)
       tmp_sad = Sad(MarcoBlock,Windows(i:i + 15,j:j + 15)); 
       if tmp_sad < sad || ((tmp_sad == sad) && VectorLength(i,j) < VectorLength(vh,vw));
           sad = tmp_sad;
           vh = i;
           vw = j;
       end
    end
end
VectorRow = vh - 17; %注意,座标是从(1,1)开始的,不同与c里的座标。
VectorCol = vw - 17;

function VL = VectorLength(a,b)
%计算离零点的距离平方

VL = (a - 17)^2 + (b - 17)^2;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -