MATLAB: Check if the code is correct or not for finding the diameter of objects in an image.

image processingImage Processing Toolboximage segmentation

Sir here I attached the code for finding the diameter of irregularly shaped objects in an image. Tell me if the code is correct to find the diameter or not .
if true
% code
end
originalImage = imread('result.jpg');
originalImage=rgb2gray(originalImage);
labeledImage = bwlabel(originalImage, 8);
D=regionprops(labeledImage,'area');
d1=regionprops(labeledImage,'EquivDiameter');

Best Answer

No, you need to create a binary image first, plus you can do it all in one call to regionprops():
originalImage = imread('result.jpg');
originalImage=rgb2gray(originalImage);
binaryImage = originalImage > thresholdValue; % for example 80 or 142 or some value.
labeledImage = bwlabel(binaryImage, 8);
D=regionprops(labeledImage,'area','EquivDiameter');
Related Question