SAD with full search range [-6,6]

9 views (last 30 days)
Lefteris Kostakis
Lefteris Kostakis on 28 Nov 2019
Commented: Lefteris Kostakis on 28 Nov 2019
I have an image divided in 16x16 macroblocks and another image 144x176 and I want to calculate SAD for each macroblock in range of [-6,6] for vectors (i,j) using full search
lets assume m=144 and n=176 so my macroblocks cell has dimensions 144/16 176/16 = 9x11 I want to take the sum of absolute differences from each macroblock and the 144x176 image. The problem is that I go out of limits of my image array or I go till the end of the rows and columns instead I only need the values that are +-6.
Any idea ?
for i =1:1:9 %i take each 16x16 macroblock
for j =1:1:11
for k=6:1:m
for l=6:1:n
kl=kl+sum(abs(macroblocks{i,j} - image(k-5:k+5,l-5:l+5)));
end
end
end
end

Answers (1)

Image Analyst
Image Analyst on 28 Nov 2019
Try blockproc(). I attach demos where I use it for other functions.
  5 Comments
Image Analyst
Image Analyst on 28 Nov 2019
OK, so do it with for loops but I think it will make the computation of the row and column indexes easier if you use imresize() to make them the same size.
Lefteris Kostakis
Lefteris Kostakis on 28 Nov 2019
thats why i posted, to get help doing it with for loops :P

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!