Skip to content

Commit

Permalink
Starting implementing local extrema detection algorithm.
Browse files Browse the repository at this point in the history
delete
  • Loading branch information
JustinLiang authored and Justin Liang committed Apr 17, 2017
1 parent adc7840 commit e1c1e37
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 2 deletions.
Binary file removed CannyEdgeDetector/Test_Photos/test5.jpg
Binary file not shown.
28 changes: 28 additions & 0 deletions SIFT/DetectLocalExtrema.asv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function DetectLocalExtrema(pyramid)
for octaveNum=1:size(pyramid,2) % Iterate through the octaves
for scaleNum=1:size(pyramid{1},2)-2 % Iterate through the scales
[h,w] = size(pyramid{octaveNum}{scaleNum});
for row=2:h-1 % Iterate through rows
for col=2:w-1 % Iterate through cols
CompareNeighbors(pyramid, octaveNum, scaleNum);
end
end
end
end
end

% Compares the neighbors for all the pixels
function CompareNeighbors(pyramid, octaveNum, scaleNum)
% Compare the 26 neighbors
for i=-1:1:1
for j=-1:1:1
for k=0:2
if pyramid{octaveNum}{scaleNum}(row,col) < ...
pyramid{octaveNum}{scaleNum+k}(row+i,col+j)
return;
end
end
end
end

end
38 changes: 38 additions & 0 deletions SIFT/DetectLocalExtrema.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function [localExtrema] = DetectLocalExtrema(pyramid)
% THRESHOLD =
localExtrema = {};
count = 0;
for octaveNum=1:size(pyramid,2) % Iterate through the octaves
for scaleNum=1:size(pyramid{1},2)-2 % Iterate through the scales
[h,w] = size(pyramid{octaveNum}{scaleNum});
for row=2:h-1 % Iterate through rows
for col=2:w-1 % Iterate through cols
count = count + 1;
temp = CompareNeighbors(pyramid, octaveNum, scaleNum, row, col);
if ~isempty(temp)
localExtrema(end+1) = temp;
end
end
end
end
end
count
end

% Compares the neighbors for all the pixels
function [localExtrema] = CompareNeighbors(pyramid, octaveNum, scaleNum, row, col)
% Compare the 26 neighbors
for i=-1:1:1
for j=-1:1:1
for k=0:2
if pyramid{octaveNum}{scaleNum+1}(row,col) < ...
pyramid{octaveNum}{scaleNum+k}(row+i,col+j)
localExtrema = {};
return;
end
end
end
end
localExtrema = {[row,col]};

end
2 changes: 1 addition & 1 deletion SIFT/MakePyramid.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% in the template
function[pyramid] = MakePyramid(im, octaves)
SCALE = 1.6;
SCALES_PER_OCTAVE = 3;
SCALES_PER_OCTAVE = 4;
K = sqrt(2);
RATIO = 0.5;

Expand Down
4 changes: 3 additions & 1 deletion SIFT/SIFT.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ function CannyEdgeDetector()

pyramid = ComputeDifferenceOfGaussian(pyramid);
ShowPyramid(pyramid);


localExtrema = DetectLocalExtrema(pyramid);
test = 5;
end

0 comments on commit e1c1e37

Please sign in to comment.