%% main.m
% Danieljf24, 8/12/14 [danieljianfeng24@gmail.com]
clear all;close all;
%% load image and convert to gary image
I = imread('source1.jpg');
GrayI = rgb2gray(I);
%% set the gaussian filter with variance 1 and 10 respectively
g1 = fspecial('gaussian', [7 7], 1);
g10 = fspecial('gaussian', [7 7], 10);
f1 = imfilter(GrayI, g1, 'replicate');
f10 = imfilter(GrayI, g10, 'replicate');
%% Plot the image with gaussian filter
figure(1);
subplot(221); imshow(I);title('source');
subplot(222); imshow(GrayI);title('gary image');
subplot(223); imshow(f1);title('delta = 1');
subplot(224); imshow(f10);title('delta = 10');
%% Plot the image of DoG(Difference of Gaussian)
figure(2);
% negative value will occur leading to wrong outcome
% uint8 cannot hold negative value, so it will be 0
%subplot(121);imshow(f10 - f1);title('wrong');
subplot(121);imshow(scaleImg1(double(f10) - double(f1)));title('method 1');
subplot(122);imshow(scaleImg2(double(f10) - double(f1)));title('method 2');