baseFileName = "vertebral disk.jpeg";
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));
rgbImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(rgbImage)
if numberOfColorChannels == 3
grayImage = rgb2gray(rgbImage);
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
g.WindowState = 'maximized';
g.Name = 'Demo by Image Analyst';
title('Gray Scale Histogram', 'FontSize', fontSize, 'Interpreter', 'None');
xline(thresholdValue, 'Color', 'r');
mask = grayImage > thresholdValue;
[~, numberOfBlobs] = bwlabel(mask);
caption = sprintf('Initial Mask Image with %d blobs', numberOfBlobs);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
mask = imfill(mask, 'holes');
mask = bwareafilt(mask, 1);
title('Final Mask Image', 'FontSize', fontSize, 'Interpreter', 'None');
blobMeasurements = regionprops(mask, 'Area', 'EquivDiameter');
numberOfBlobs = size(blobMeasurements, 1)
allAreas = [blobMeasurements.Area]
allDiameters = [blobMeasurements.EquivDiameter]
caption = sprintf('Final Mask Image with %d Blob', numberOfBlobs);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');