how bounding box detect letter in binary image

조회 수: 3 (최근 30일)
Samreen kayani
Samreen kayani 2019년 1월 9일
댓글: Samreen kayani 2019년 1월 9일
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);
  댓글 수: 1
Samreen kayani
Samreen kayani 2019년 1월 9일
I want to save 15.92 in variable or write in file

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by