Info

This question is closed. Reopen it to edit or answer.

Hi, I am finding difficulty in drawing bounding boxes for n number of images. My code is able to read only three images out of 10. Can anybody debug my code?

1 view (last 30 days)
srcFiles = dir('C:\Users\Admin\Pictures\georgebush\*.BMP'); % the folder in which ur images exists for it = 1:length(srcFiles) it filename = strcat('C:\Users\Admin\Pictures\georgebush\',srcFiles(it).name); rdcrop = imread(filename); %figure, imshow(rdcrop); bw=im2bw(rdcrop,0.9); b=logical(bw); j=~b; figure , imshow(j) [Ilabel_num]=bwlabel(j) Iprops=regionprops(Ilabel_num) Ibox1=[Iprops.BoundingBox]; Ibox=reshape(Ibox1 ,[4 length(Ibox1)/4]); figure ; cnt_subplot=0; for cnt=1:length(Ibox) rectangle('position',Ibox(:,cnt),'edgecolor','r'); out=ceil(Ibox(1:2,cnt))'; start_OCR_col=out(1,1); start_OCR_row=out(1,2); end_OCR_col=start_OCR_col+ceil(Ibox(3,cnt))-1; end_OCR_row=start_OCR_row+ceil(Ibox(4,cnt))-1; img_crop_char=j(start_OCR_row:end_OCR_row,start_OCR_col:end_OCR_col); [pixel_rows(1,cnt) pixel_cols(1,cnt)]=size(img_crop_char); cnt end
end

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!