Now , i have image called "test.png" and my question is how to detect circles with & without holes and display each of them in single figure and here is my code but desn't work with me , so need help
I = imread('test.png');imshow(I);I = rgb2gray(I);I = im2bw(I,0.01);[L ,num] = bwlabel(I);stats1 = regionprops (L,'EulerNumber' , 'Area' , 'Perimeter' , 'BoundingBox');sum = 0;for R=1:num% this way desn't work but maybe it just need a little changes
% x = uint8 (stats1(R).BoundingBox(1));
% y = uint8 (stats1(R).BoundingBox(2));
% if (I(x,y) == 0)
% sum = sum + 1;
% bb = stats1(R).BoundingBox;
% rectangle('position',bb,'edgecolor','r','linewidth',1.3);
% end
circularity = (stats1(R).Perimeter .^ 2) ./ (4 * pi * stats1(R).Area); if (circularity >= 1.1) sum = sum + 1; bb = stats1(R).BoundingBox; rectangle('position',bb,'edgecolor','r','linewidth',1.3); endenddisp(sum);
Best Answer