From: abhi m on
Am not understanding the logic used behind this code can anyone help me... below code is used to recognise shape of the object such as square,ellipse,cirlce,triangle,rectangle,diamond.....

bw = imfill(erodedImage,'holes');
L = bwlabel(bw);
S=rgbImage;
s = regionprops(L, 'centroid');
dt = regionprops(L, 'area');
dim = size(s);
BW_filled = imfill(bw,'holes');
boundaries = bwboundaries(BW_filled);
figure,imshow(S);
hold on;
size(boundaries)
for k=1:dim(1)
b= boundaries{k};
dim = size(b);
for i=1:dim(1)
khoangcach{k}(1,i) = sqrt ( ( b(i,2) - s(k).Centroid(1) )^2 + ( b(i,1) - s(k).Centroid(2) )^2 );
end
a=max(khoangcach{k});
b=min(khoangcach{k});
c=dt(k).Area;