Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ind map] = imread('http://i.gyazo.com/0ca8d4416a52b8bc3401da0b71a527fd.gif'); %//read indexed image
- BW = max( ind2rgb(ind,map), [], 3 ) > .15; %//convert RGB image to binary mask
- seg = regionprops( BW.', 'Image' ); %'// transpose input mask
- seg = arrayfun( @(x) x.Image.', seg, 'Uni', 0 ); %'// flip back
- im = imread('http://i.stack.imgur.com/q7cnA.png');
- se = strel('square', 7);
- im_close = imclose(im, se);
- s = regionprops(im_close, 'BoundingBox');
- [x y w h]
- bb = round(reshape([s.BoundingBox], 4, []).');
- imshow(im);
- for idx = 1 : numel(s)
- rectangle('Position', bb(idx,:), 'edgecolor', 'red');
- end
- chars = cell(1, numel(s));
- for idx = 1 : numel(s)
- chars{idx} = im(bb(idx,2):bb(idx,2)+bb(idx,4)-1, bb(idx,1):bb(idx,1)+bb(idx,3)-1);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement