diff --git a/CannyEdgeDetector/Test_Photos/test5.jpg b/CannyEdgeDetector/Test_Photos/test5.jpg deleted file mode 100644 index 8e24aa5..0000000 Binary files a/CannyEdgeDetector/Test_Photos/test5.jpg and /dev/null differ diff --git a/SIFT/DetectLocalExtrema.asv b/SIFT/DetectLocalExtrema.asv new file mode 100644 index 0000000..f10cc8d --- /dev/null +++ b/SIFT/DetectLocalExtrema.asv @@ -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 diff --git a/SIFT/DetectLocalExtrema.m b/SIFT/DetectLocalExtrema.m new file mode 100644 index 0000000..ed8001a --- /dev/null +++ b/SIFT/DetectLocalExtrema.m @@ -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 diff --git a/SIFT/MakePyramid.m b/SIFT/MakePyramid.m index beda123..fae2c11 100644 --- a/SIFT/MakePyramid.m +++ b/SIFT/MakePyramid.m @@ -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; diff --git a/SIFT/SIFT.m b/SIFT/SIFT.m index ec47d43..a1b39d9 100644 --- a/SIFT/SIFT.m +++ b/SIFT/SIFT.m @@ -18,5 +18,7 @@ function CannyEdgeDetector() pyramid = ComputeDifferenceOfGaussian(pyramid); ShowPyramid(pyramid); - + + localExtrema = DetectLocalExtrema(pyramid); + test = 5; end