我只想识别较小的正方形组,我需要一些关于该效果的提示。[/ p>]
I = imread('q1.jpg');
Ibw = ~im2bw(I,graythresh(I));
Ifill = imfill(Ibw,'holes');
Iarea = bwareaopen(Ifill,100100);
stat = regionprops(Iarea,'boundingbox');
imshow(I); hold on;
for cnt = 1 : numel(stat)
bb = stat(cnt).BoundingBox;
rectangle('position',bb,'edgecolor','r','linewidth',2);
end