clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 22;
folder = pwd;
baseFileName = 'crossing_table1.mat';
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
s = load(fullFileName)
binaryImage = s.crossing_table;
hFig = figure;
subplot(1, 2, 1);
imshow(binaryImage, []);
title('Original Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image');
hp = impixelinfo();
hFig.WindowState = 'maximized';
[rows, columns] = size(binaryImage)
binaryImage2 = binaryImage & ~bwareaopen(binaryImage, 300);
binaryImage2 = triu(binaryImage2, 1);
subplot(1, 2, 2);
imshow(binaryImage2, []);
title('Masked Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image');
hp = impixelinfo();
props = regionprops(binaryImage2, 'Area', 'Centroid', 'PixelList');
allAreas = [props.Area]
centroids = vertcat(props.Centroid);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')