From adc784096f0e22ef7dd709c0bce3be5bbfaabb4d Mon Sep 17 00:00:00 2001 From: JustinLiang Date: Mon, 21 Mar 2016 00:07:38 -0700 Subject: [PATCH] Implemented difference of gaussian algorithm. --- SIFT/ComputeDifferenceOfGaussian.asv | 14 ++++++++++++++ SIFT/ComputeDifferenceOfGaussian.m | 14 ++++++++++++++ SIFT/SIFT.m | 6 +++++- SIFT/ShowPyramid.m | 3 ++- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 SIFT/ComputeDifferenceOfGaussian.asv create mode 100644 SIFT/ComputeDifferenceOfGaussian.m diff --git a/SIFT/ComputeDifferenceOfGaussian.asv b/SIFT/ComputeDifferenceOfGaussian.asv new file mode 100644 index 0000000..64aed5d --- /dev/null +++ b/SIFT/ComputeDifferenceOfGaussian.asv @@ -0,0 +1,14 @@ +% This function computes the difference in gaussian and outputs a new pyramid +function gaussianPyramid = ComputeDifferenceOfGaussian(pyramid) + if isempty(pyramid) + return + end + + gaussianPyramid = {}; % Initialize difference of gaussian cell array + + for i=1:size(pyramid,2) % Iterate through the octaves + for j=1:size(pyramid{1},2)-1 % Iterate through the scales + gaussianPyramid{i}{j} = pyramid{i}{j} - pyramid{i; + end + end +end \ No newline at end of file diff --git a/SIFT/ComputeDifferenceOfGaussian.m b/SIFT/ComputeDifferenceOfGaussian.m new file mode 100644 index 0000000..4b55dea --- /dev/null +++ b/SIFT/ComputeDifferenceOfGaussian.m @@ -0,0 +1,14 @@ +% This function computes the difference in gaussian and outputs a new pyramid +function gaussianPyramid = ComputeDifferenceOfGaussian(pyramid) + if isempty(pyramid) + return + end + + gaussianPyramid = {}; % Initialize difference of gaussian cell array + + for i=1:size(pyramid,2) % Iterate through the octaves + for j=1:size(pyramid{1},2)-1 % Iterate through the scales + gaussianPyramid{i}{j} = pyramid{i}{j+1} - pyramid{i}{j}; + end + end +end \ No newline at end of file diff --git a/SIFT/SIFT.m b/SIFT/SIFT.m index 9bba8d2..ec47d43 100644 --- a/SIFT/SIFT.m +++ b/SIFT/SIFT.m @@ -1,7 +1,7 @@ % Perform edge detection with interpolation during non maximum suppression function CannyEdgeDetector() close all; % Close figures - OCTAVES = 4; + OCTAVES = 3; % Change the current folder to the folder of this m-file. % Courtesy of Brett Shoelson @@ -15,4 +15,8 @@ function CannyEdgeDetector() pyramid = MakePyramid(im,OCTAVES); ShowPyramid(pyramid); + + pyramid = ComputeDifferenceOfGaussian(pyramid); + ShowPyramid(pyramid); + end diff --git a/SIFT/ShowPyramid.m b/SIFT/ShowPyramid.m index 0de66ba..76ad723 100644 --- a/SIFT/ShowPyramid.m +++ b/SIFT/ShowPyramid.m @@ -15,8 +15,9 @@ function ShowPyramid(pyramid) end end + figure; for i=1:length(pyramidImage) - figure; + subplot(length(pyramidImage),1,i); imshow(pyramidImage{i}); end end \ No newline at end of file