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 件のコメント

darova
darova 2020 年 5 月 10 日
Can't you just use part of the second matrix?
fmvs_x - ffmpeg_mvs_x(1:85,1:155)
ImageAnalyst
ImageAnalyst 2020 年 5 月 10 日
if i follow this way then i loose the vectors beyond a certain range
darova
darova 2020 年 5 月 11 日
Can you attach the data?
ImageAnalyst
ImageAnalyst 2020 年 5 月 11 日
Please find attched

サインインしてコメントする。

 採用された回答

darova
darova 2020 年 5 月 11 日

0 投票

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 件のコメント

ImageAnalyst
ImageAnalyst 2020 年 5 月 11 日
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)
darova
darova 2020 年 5 月 11 日
No. It's the best solution you can find
Image Analyst
Image Analyst 2020 年 5 月 11 日
You could try imresize() to do a bicubic interpolation of the matrix.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

タグ

質問済み:

2020 年 5 月 10 日

コメント済み:

2020 年 5 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by