Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. I = imread('F:h.png');
  2. info = imfinfo('F:h.png');
  3. I1 = ~im2bw(I);
  4. I2 = bwlabel(I1);
  5. S = regionprops(I2, {'BoundingBox'});
  6. [m,n] = size(S);
  7. for a=1:m
  8. for b=1:n
  9. width = S(a,b).BoundingBox(3);
  10. height = S(a,b).BoundingBox(4);
  11. if width==height
  12. display('square');
  13. else
  14. display('rectangle');
  15. end
  16. display(width);
  17. display(height);
  18. pause(2)
  19. end
  20. end
  21.  
  22. I = imread('F:h.png');
  23. info = imfinfo('F:h.png');
  24. I1 = ~im2bw(I);
  25. I2 = bwlabel(I1);
  26. S = regionprops(I2, {'BoundingBox'});
  27. [m,n] = size(S);
  28. for a=1:m
  29. for b=1:n
  30. width = S(a,b).BoundingBox(3);
  31. height = S(a,b).BoundingBox(4);
  32. if width==height
  33. display('square');
  34. text(S(a,b).Centroid, 'square')
  35. else
  36. display('rectangle');
  37. text(S(a,b).Centroid, 'rectangle')
  38. end
  39. display(width);
  40. display(height);
  41. pause(2)
  42. end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement