|
- I = imread('count.png');
- subplot(2,3,1);imshow(I);
- I_gray = rgb2gray(I);
- I_bw = I_gray< 100;
- subplot(2,3,2);imshow(I_bw,[]);
- I_circle = zeros(size(I_bw));
- [I_label,num] = bwlabel(I_bw);
- subplot(2,3,3);imshow(I_label,[]);
- for i = 1:num
- I_bw1 = I_label == i;
- subplot(2,3,4);imshow(I_bw1,[]);
- S1 = sum(sum(I_bw1));
- I_edge1 = abs(imfilter(double(I_bw1)...
- ,[-1,1]));
- I_edge2 = abs(imfilter(double(I_bw1)...
- ,[-1;1]));
- I_edge = (I_edge1 +I_edge2 )>0;
- subplot(2,3,5);imshow(I_edge,[]);
- L = sum(sum(I_edge));
- R = 4*pi*S1/L^2
- if R > 0.8
- I_circle = I_circle + I_bw1;
- end
- end
- subplot(2,3,6);imshow(I_circle,[]);
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|