MATLAB: How can i draw circles on every black pixel area and keep the maximum circle that fit the black areas to find the fiber pore size

fiberimage processingImage Processing Toolbox

Here is my image
I do not know how to select those black areas and draw circles on every black areas to find the mean pore size. Need help.

Best Answer

Invert the image, Then ask regionprops for the area or equivalent circular diameter, and centroid
binaryImage = grayImage < 128;
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'Area', 'EquivDiameter', 'Centroid');
allAreas = [measurements.Area]
allDiams = [measurements.EquivDiameter]
allCentroids = [measurements.Centroid]
xCentroids = allCentroids(1:2:end);
yCentroids = allCentroids(2:2:end);
% Plot red circles over centroids
plot(xCentroids, yCentroids, 'ro', 'MarkerSize', 10, 'LineWidth', 2);
% Get mean ECD (pore size)
meanDiameter = mean(allDiams);
Related Question