MATLAB Answers

Exhaustive Block Matching Algorithm

32 views (last 30 days)
Hi all,
I'm trying to write the Exhaustive Block Matching Algorithm based on the pseudo-code written in this slide: http://inst.eecs.berkeley.edu/~ee290t/sp04/lectures/motion_estimation.pdf
I think I wrote my programme not correctly but don't know where I was wrong. Can anyone please help me? Thank you very much :(

  1 Comment

Jan
Jan on 1 Feb 2012
It is very likely, that someone is assisting to solve the problems if you post the corresponding code and explain, what's going wrong. Currently the best answer is: "yes".

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Feb 2012
On one of the lines, you have a typing mistake.

  1 Comment

Tuan Nguyen
Tuan Nguyen on 7 Feb 2012
I'm sorry about that since my English is not so good.

Sign in to comment.

More Answers (2)

Tuan Nguyen
Tuan Nguyen on 7 Feb 2012
Oh I'm so sorry for forgetting posting my code. This is my matlab code written for exhaustive block matching algorithm
function motionVect = motionEst(f1,f2,N,R)
[height width] = size(f2);
figure,imshow(f2);
hold on;
for i = 1:N:height-N
for j = 1:N:width-N
MAD_min = 256;
mvx = 0;
mvy = 0;
for k = -R:1:R
for l = -R:1:R
%MAD=sum(sum(abs(f1(i:i+N-1,j:j+N-1)-f2(i+k:i+k+N-1,j+l:j+l+N-1))));
MAD = 0;
for u = i:i+N-1
for v = j:j+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
iblk = floor((i-1)/(N+1))+1;
jblk = floor((j-1)/(N+1))+1;
mvx(iblk,jblk) = dx;
mvy(iblk,jblk) = dy;
%figure, imshow(f2);
%hold on;
arrow([i j],[i+dy j+dx], 3);
end
end
And this is the pseudo-code on which I based to write my code
I have a doubt that there might be something wrong with the lines in my code which calculate MAD but I'm not so sure about that.
Can anyone please help me with this problem?
Thanks very much.

  3 Comments

Neda Azarmehr
Neda Azarmehr on 14 May 2017
Hi
I am wondering what is N, R, and K on this code. Could anyone help me about it?
Regards, Neda
Walter Roberson
Walter Roberson on 14 May 2017
N is the block size. R is the search range. K is the current search location.
Felipe Ayres
Felipe Ayres on 16 Nov 2017
aren't dy and dx switched?

Sign in to comment.


beppo
beppo on 22 Nov 2017
Hi, what is the arrow function at the very bottom? Also, is the code working or not? Thanks