-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexhaustiveSearchAlgorithm.m
More file actions
29 lines (26 loc) · 1.03 KB
/
exhaustiveSearchAlgorithm.m
File metadata and controls
29 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [ xShift, yShift, differenceMatrix] = exhaustiveSearchAlgorithm(currentMacroBlock,referenceSearchWindow)
% Finds loop count.
[swRow, swColumn] = size(referenceSearchWindow);
[mbRow, mbColumn] = size(currentMacroBlock);
rowTraverse = (swRow-mbRow)+1;
columnTraverse = (swColumn-mbColumn)+1;
minSAD = 0;
xShift = 0;
yShift = 0;
differenceMatrix = zeros(mbRow, mbColumn,'double');
%%
% Sum of Absolute Difference (SAD).
for p = 1:rowTraverse;
for q = 1:columnTraverse;
tempDifferenceMatrix = currentMacroBlock - referenceSearchWindow(p:(p+15),q:(q+15));
SADValue = sum(sum(abs(tempDifferenceMatrix)));
% Calculates Min SAD and corresponding diff_matrix and X and Y pixels.
if ((SADValue < minSAD)||(xShift == 0 && yShift == 0))
minSAD = SADValue;
xShift = p;
yShift = q;
differenceMatrix = tempDifferenceMatrix;
end
end
end
end