资源简介

利用前后两关键帧图片生成边信息,两种方法:帧插值和前向估计。

资源截图

代码片段和文件信息

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)
                                    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
 

评论

共有 条评论