Calculate Difference between motion vectors

I have motion vectors from two different blockmatchers.
1) fmvs_x, fmvs_y
matrix size -90 x 160
2) ffmpeg_mvs_x, ffmpeg_mvs_y
matrix size - 92 x 160
so the vector difference would be magnitude of (fmvs_x - ffmpeg_mvs_x ) - (fmvs_y - ffmpeg_mvs_y). But the problem is that both the vectors have different matrix sizes.
Could you please advise how should I scale the size of matrix to get correct result.

4 个评论

Can't you just use part of the second matrix?
fmvs_x - ffmpeg_mvs_x(1:85,1:155)
if i follow this way then i loose the vectors beyond a certain range
Can you attach the data?

请先登录,再进行评论。

 采纳的回答

Make matrices the same size with interp2
clc,clear
x = xlsread('motionvectors.xls',1);
y = xlsread('motionvectors.xls',2);
fx = xlsread('motionvectors.xls',3);
fy = xlsread('motionvectors.xls',4);
%%
clc
[m,n] = size(x); % size of x data
[fm,fn] = size(fx); % size of fx data
[xx,yy] = meshgrid(1:n,1:m); % interpolation grid of 'x' matrix
xt1 = linspace(1,n,fn); % interpolation vectors of 'fx' matrix
yt1 = linspace(1,m,fm);
[fxx,fyy] = meshgrid(xt1,yt1); % interpolation grid of 'fx' matrix
x1 = interp2(fxx,fyy,fx,xx,yy); % interpolate data
y1 = interp2(fxx,fyy,fy,xx,yy);
h1 = surf(xx,yy,x1,'facecolor','r');
h2 = surface(fxx,fyy+100,fx,'facecolor','b');
set([h1 h2],'edgecolor','none')
legend('interpolated data','original data','location','north')
axis vis3d
x-x1; % difference

3 个评论

Is there any other simple one rather than using interp2. Something like just scaling the matrix size of 90 x 160 to 92 x 160 using size(92 x 160)
No. It's the best solution you can find
You could try imresize() to do a bicubic interpolation of the matrix.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by