Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function image = ques4(I)
- bin = imbinarize(rgb2gray(I));
- inv_bin = ~ bin;
- [Lo, numo] = bwlabel(bin);
- [Lh, numh] = bwlabel(inv_bin);
- cnt = 0;
- numh = numh -1;
- stateo=regionprops (Lo, 'BoundingBox');
- stateh=regionprops (Lh, 'BoundingBox')
- s = 1;
- for i = 1 : numo
- Xo=uint64(stateo(i).BoundingBox(1));
- Yo=uint64(stateo(i).BoundingBox(2));
- Wo=stateo(i).BoundingBox(3);
- Ho=stateo(i).BoundingBox(4);
- if(bin(Yo, Xo) == 1)
- for j = 1 : numh
- Xh=uint64(stateh(j).BoundingBox(1));
- Yh=uint64(stateh(j).BoundingBox(2));
- Wh=stateh(j).BoundingBox(3);
- Hh=stateh(j).BoundingBox(4);
- if (Xh>Xo && Yh>Yo && Xh<(Xo+Wo) && Yh<(Yo+Ho))
- image(s)=stateo(i);
- s = s + 1;
- break;
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement