clc;
close all;
clear;
workspace;
format short g;
format compact;
fontSize = 25;
baseFileName = 'netmuscle.jpg';
folder = [];
fullFileName = fullfile(folder, baseFileName);
grayImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
grayImage = grayImage(:, :, 3);
end
subplot(1, 2, 1);
imshow(grayImage, []);
axis on;
axis image;
caption = sprintf('Original Gray Scale Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0, 1, 1]);
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
subplot(1, 2, 2);
histogram(grayImage);
grid on;
se = strel('disk', 15);
filteredImage = imbothat(grayImage, se);
imshow(filteredImage, []);
histogram(filteredImage);
grid on;
binaryImage = filteredImage >35;
binaryImage = bwareafilt(binaryImage, [100, 800]);
subplot(1, 2, 2);
imshow(binaryImage, []);
axis on;
axis image;
caption = sprintf('Binary Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
[labeledImage, numBlobs] = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Area');
allAreas = [props.Area]
sortedAread = sort(allAreas)
caption = sprintf('Binary Image with %d Muscle Fibers', numBlobs);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
Best Answer