Motion vector calculation

9 views (last 30 days)
Vignesh
Vignesh on 1 Apr 2012
Commented: shriya patil on 1 Jul 2019
I am doing a project in Image processing "Grouping similar images in a video using Motion vectors and segmentation". In that, a video is seperated into frames(334 frames), and all the frames are divided into 8 * 8 blocks. With Image analyst and Kye taylor`s help, i managed to divide all the frames into 8 * 8 blocks. Now, I need to calculate the motion vectors for each block using Block matching concept. I used the following code
R=10;N=8;
for x = 1:N:height-N
for y = 1:N:width-N
MAD_min = 256;
mvx = 0;
mvy = 0;
for k = -R:1:R
for l = -R:1:R
MAD = 0;
for u = x:x+N-1
for v = y:y+N-1
if ((u+k > 0)&&(u+k < height + 1)&&(v+l > 0)&&(v+l < width + 1))
MAD = MAD + abs(f1(u,v)-f2(u+k,v+l));
end
end
end
MAD = MAD/(N*N);
if (MAD<MAD_min)
MAD_min = MAD;
dy = k;
dx = l;
end
end
end
xblk = floor((x-1)/(N+1))+1;
yblk = floor((y-1)/(N+1))+1;
mvx(xblk,yblk) = dx;
mvy(xblk,yblk) = dy;
end
end
I referred it somewhere here.
f1- anchor frame, f2-target frame. I think the code is working and the motion vectors are found. But, I want to know how the motion vectors are calculated here. Can anybody give the description for this code?
  1 Comment
shriya patil
shriya patil on 1 Jul 2019
isn't it taking too long time for execution process??

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!