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:
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 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);
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 = 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));
MAD = MAD/(N*N);
if (MAD<MAD_min)
MAD_min = MAD;
dy = k;
dx = l;
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);
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.


Neda Azarmehr
Neda Azarmehr on 14 May 2017
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 on 22 Nov 2017
Hi, what is the arrow function at the very bottom? Also, is the code working or not? Thanks