MATLAB: How to calculate diameter of circular image

applediameterexcutable filefruitimage processingImage Processing ToolboxMATLAB Compiler

Hello I`m new in matlab and I have two questions:
1 and most important, I want to know if there is there any function or code to calculate diameter of circular object in an image, like an apple for example:
2. I want to exe (converting to exe file) my project that has a 6 gui windows, how to do that???
Thanks for everyone!!

Best Answer

See my Image Processing Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 You can threshold the object and ask regionprops for the EquivDiameter, the equivalent circular diameter, which is the diameter of a circle with the same number of pixels as your object. Basically, threshold then
binaryImage = grayImage < 200; % Or whatever number works.
binaryImage = bwareafilt(binaryImage, 1); % Extract only the largest blob. R2014b and later.
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'EquivDiameter');
ecd = props(1).EquivDiameter