資源簡介
利用前后兩關鍵幀圖片生成邊信息,兩種方法:幀插值和前向估計。
代碼片段和文件信息
function?[?img?]?=?SideI(?img1?img2?method)
%?method?=?0?->?frame?interpolation
%?method?=?1?->?forword?motion?estimation
block?=?16;???%block?size
sr?=?7;?????????%search?range
[?height?width?]?=?size(img2);
img?=?zeros(?height?width);
if(method>1)
????imgb?=?zeros(height?width);
end
[?h1?w1?]?=?size(img1);
if(h1?~=?height?||?w1?~=?width)
????disp(‘images?size?are?not?equal‘)
else
????switch?method
????????case?0??%?0?->?frame?interpolation
????????????img?=?(img1+img2)/2;
????????case?1??%?1?->?forword?motion?estimation
????????????[?height?width?]?=?size(img2);
????????????for?h=1:block:height
????????????????for?w=1:block:width
????????????????????maxSAD?=?65535;
????????????????????for?y=-sr:sr
????????????????????????for?x=-sr:sr????????????????????????
????????????????????????????if?(?h+y>=1?&&?h+y<=height-block?&&?w+x>=1?&&?w+x?<=width-block)
????????????????????????????????SAD?=?0;
????????????????????????????????for?j=0:15
????????????????????????????????????for?i=0:15
????????????????????????????????????????SAD?=?SAD?+?abs(?img2(h+jw+i)?-?img1(h+y+jw+x+i));
????????????????????????????????????end
????????????????????????????????end
????????????????????????????????if(?SAD?????????????????????????????????????maxSAD?=?SAD;
????????????????????????????????????mvx?=?x;
????????????????????????????????????mvy?=?y;
????????????????????????????????end
????????????????????????????end
????????????????????????end
????????????????????end
????????????????????for?j=0:15
????????????????????????for?i=0:15
????????????????????????????img(?h+j?w+i?)?=?img1(?h+floor(mvy/2)+j??w+floor(mvx/2)+i?);
????????????????????????end
????????????????????end
????????????????end
????????????end
????????case?2???????????%(forward?MC?+?backward?MC)?/2
?
評論
共有 條評論