fprintf('Beginning to run %s.m ...\n', mfilename);
baseFileName = 'image.PNG';
fullFileName = fullfile(folder, baseFileName);
fullFileNameOnSearchPath = baseFileName;
if ~exist(fullFileNameOnSearchPath, 'file')
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
fullFileName = fullFileNameOnSearchPath;
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(rgbImage)
caption = sprintf('Original Image : "%s"', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hFig1.Units = 'Normalized';
hFig1.WindowState = 'maximized';
hFig1.Name = 'Demo by Image Analyst';
grayImage = rgb2gray(rgbImage);
caption = sprintf('Gray Scale Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
mask = bwareafilt(mask, 1);
caption = sprintf('Mask Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
props = regionprops(mask, 'BoundingBox');
croppedImage = imcrop(rgbImage, props.BoundingBox);
imshow(croppedImage, []);
caption = sprintf('Cropped Image ');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');