Borrar filtros
Borrar filtros

how bounding box detect letter in binary image

1 visualización (últimos 30 días)
Samreen kayani
Samreen kayani el 9 de En. de 2019
Comentada: Samreen kayani el 9 de En. de 2019
clc
clear all
close all%% Read Image
Inputimage=imread('manhoos.jpg');
%Inputimage=imread('DMM3.png');
%% Show image
Inputimage=imcrop(Inputimage)
figure(1)
imshow(Inputimage);
title('INPUT IMAGE WITH NOISE')
x=[];
%% Convert to gray scale
if size(Inputimage,3)==3 % RGB image
Inputimage=rgb2gray(Inputimage);
end
%% Convert to binary image
threshold = graythresh(Inputimage);
Inputimage =~im2bw(Inputimage,threshold);
word=[ ];
%% Remove all object containing fewer than 30 pixels
Inputimage=im2bw(Inputimage)
Inputimage1 = bwareaopen(Inputimage,10);
% Inputimage2 = bwmorph(Inputimage1,'remove');
% Inputimage = bwmorph(Inputimage2,'skel',Inf);
re=Inputimage1;
while (1)
%Fcn 'lines' separate lines in text
[fl re]=lines(re);
imgn=fl
%Uncomment line below to see lines one by one
%imshow(fl);pause(0.5)
%-----------------------------------------------------------------
% Label and count connected components
[L Ne] = bwlabel(Inputimage);
for n=1:Ne
[r,c] = find(L==n);
n1=imgn(min(r):max(r),min(c):max(c));
% Resize letter (same size of template)
figure
imshow(n1);pause(0.5)
% img_r=imresize(n1,[42 24]);
% % Sort boxes by image height
% s = regionprops(n1,'BoundingBox');e
% bboxes = vertcat(s(:).BoundingBox);
% [~,ord] = sort(bboxes(:,2));
% bboxes = bboxes(ord,:);
% % Pre-process image to make letters thicker
% BW = imdilate(n1,strel('disk',1));
% % Call OCR and pass in location of words. Also, set TextLayout to 'word'
% ocrResults = ocr(n1,bboxes,'CharacterSet','-.0123456789','TextLayout','word');
% words = {ocrResults(:).Text}';
% words = deblank(words)
%Uncomment line below to see letters one by one
% figure
% imshow(img_r);pause(0.5)
%-------------------------------------------------------------------
% Call fcn to convert image to text
% letter=read_letter(img_r,num_letras);
% % Letter concatenation
% word=[word letter];
end
end
pause(1);

Respuestas (0)

Categorías

Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by