Advertisement
Guest User

Untitled

a guest
May 6th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. text = imread('http://i.stack.imgur.com/N4nCm.png');
  2. text = mat2gray(text);
  3.  
  4. % find threshold and chance to binary image
  5. border = graythresh(text);
  6. textbw = im2bw(text, border);
  7. imshow(textbw);
  8.  
  9. % remove noise with median filter
  10. textfilt = medfilt2(textbw);
  11.  
  12. % remove small holes in the border of the a
  13. se = strel('disk', 4);
  14. texter = imopen(textfilt, se);
  15.  
  16. % find holes
  17. s = regionprops(texter, 'BoundingBox');
  18. bb = round(reshape([s.BoundingBox], 4, []).');
  19.  
  20. % show original image with holes
  21. imshow(textbw);
  22.  
  23. for idx = 1 : numel(s)
  24. rectangle('Position', bb(idx,:), 'edgecolor', 'red');
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement