clc;
close all;
imtool close all;
clear;
workspace;
format long g;
format compact;
fontSize = 33;
folder = 'C:\Users\Mark\Documents\Temporary';
baseFileName = 'peppers.png';
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);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
numRectangles = 20;
hold on;
for k = 1 : numRectangles
x1 = columns * rand(1);
x2 = columns * rand(1);
y1 = rows * rand(1);
y2 = rows * rand(1);
edgeColor = rand(1,3);
faceColor = rand(1,3);
patch([x1,x2,x2,x1], [y1,y1,y2,y2], 'r',...
'facecolor', faceColor,...
'edgecolor', edgeColor,...
'facealpha',0.7, ...
'LineWidth', 3)
promptMessage = sprintf('Do you want to Continue processing,\nor Cancel to abort processing?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
end
Best Answer