help with regionprops in order to draw boundary
Show older comments
i have the following image

and I am using this code to draw a bounding box around the image
img=imread('li.jpg');
% figure(1)
imshow(img);
img=rgb2gray(img);
threshold = graythresh(img);
img =~im2bw(img,threshold);
img = bwareaopen(img,30);
pause(1)
imshow(~img);
[L Ne]=bwlabel(img);
regProp=regionprops(L,'BoundingBox');
hold on
for n=1:size(regProp,1)
rectangle('Position',regProp(n).BoundingBox,'EdgeColor','r','LineWidth',2)
end
hold off
pause (1)
figure
for n=1:Ne
[r,c] = find(L==n);
n1=img(min(r):max(r),min(c):max(c));
figure;
imshow(~n1);
saveas(figure(n),fullfile('C:\SegmentedCharacters',['figure' num2str(n) '.jpg']));
end
but i am unable to do so. Could anyone help me out? Thank you.
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!