Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text = imread('http://i.stack.imgur.com/N4nCm.png');
- text = mat2gray(text);
- % find threshold and chance to binary image
- border = graythresh(text);
- textbw = im2bw(text, border);
- imshow(textbw);
- % remove noise with median filter
- textfilt = medfilt2(textbw);
- % remove small holes in the border of the a
- se = strel('disk', 4);
- texter = imopen(textfilt, se);
- % find holes
- s = regionprops(texter, 'BoundingBox');
- bb = round(reshape([s.BoundingBox], 4, []).');
- % show original image with holes
- imshow(textbw);
- for idx = 1 : numel(s)
- rectangle('Position', bb(idx,:), 'edgecolor', 'red');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement