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 comentarios

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

Iniciar sesión para comentar.

 Respuesta aceptada

darova
darova el 11 de Mayo de 2020
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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Mayo de 2020

Comentada:

el 11 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by