clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 20;
folder = fileparts(which('cameraman.tif'));
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
fullFileNameOnSearchPath = baseFileName;
if ~exist(fullFileNameOnSearchPath, 'file')
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(rgbImage)
if numberOfColorChannels > 1
grayImage = rgbImage(:, :, 1);
else
grayImage = rgbImage;
end
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image');
hp = impixelinfo();
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
kernel = [-1, 1];
diffImage = conv2(double(grayImage), kernel);
subplot(2, 2, 2);
imshow(diffImage, []);
title('Difference Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image');
hp = impixelinfo();
drawnow;
subplot(2, 2, 3:4);
histogram(diffImage);
grid on;
xlabel('Difference Value', 'FontSize', fontSize);
ylabel('Count', 'FontSize', fontSize);
title('Histogram of Difference Values', 'FontSize', fontSize);
0 Comments
Sign in to comment.