clc;
close all;
imtool close all;
clear;
workspace;
fontSize = 15;
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
fullFileName = fullfile(folder, baseFileName);
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
fullFileName = baseFileName;
if ~exist(fullFileName, 'file')
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
[rows columns numberOfColorBands] = size(rgbImage);
subplot(2, 2, 1);
imshow(rgbImage, []);
title('Original Color Image', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
sigma = 7;
h=fspecial('gaussian',[35, 35], sigma);
subplot(2, 2, 2);
surfc(h);
title('Gaussian Blurring Kernel', 'FontSize', fontSize);
smoothedImage = imfilter(rgbImage, h, 'same', 'conv');
subplot(2, 2, 3);
imshow(smoothedImage, []);
title('Smoothed Color Image (Low Pass Image)', 'FontSize', fontSize);
diffImage = smoothedImage - rgbImage;
subplot(2, 2, 4);
imshow(diffImage, []);
title('Edges Image (High Pass Image)', 'FontSize', fontSize);
msgbox('Done with demo!');
Best Answer