error in reading special characters

8 views (last 30 days)
FIR
FIR on 21 Oct 2011
i am reading a text using ocr but in that i have some special characters ,my ocr doest not recognise that character,can u suggest any idea

Answers (1)

Walter Roberson
Walter Roberson on 21 Oct 2011
Either you have a bug in your OCR routine, or your OCR routine is not powerful enough to handle those characters (perhaps you have not trained it enough on those characters?)
In past postings you have described this as a problem with Notepad, as if your OCR is working correctly but writing to Notepad gets you something different. That possibility seems a bit unlikely. Have you tracked the decimal (or hex) value of the characters your OCR routine claims to find, and then in a different program tried writing exactly that pattern to Notepad to see what happens? Is your OCR routine coming up with characters that need more than 8 bits to store internally? For that matter, coming up with characters greater than 127 so that character sets and fonts start being an issue?
  12 Comments
FIR
FIR on 22 Oct 2011
% PRINCIPAL PROGRAM
warning off %#ok<WNOFF>
% Clear all
clc, close all, clear all
% Read image
imagen=imread('image.jpg');
% Show image
imshow(imagen);
title('INPUT IMAGE WITH NOISE'
% Convert to gray scale
if size(imagen,3)==3 %RGB image
imagen=rgb2gray(imagen);
end
% Convert to BW
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
% Remove all object containing fewer than 30 pixels
imagen = bwareaopen(imagen,30);
%Storage matrix word from image
%FIGURE,IM
word=[ ];
re=imagen;
%Opens text.txt as file for write
fid = fopen('text.txt', 'wt');
% Load templates
load templates
global templates
% Compute the number of letters in template file
num_letras=size(templates,2);
while 1
%Fcn 'lines' separate lines in text
[fl re]=lines(re);
imgn=fl;
%Uncomment line below to see lines one by one
figure,imshow(fl);pause(0.5)
%-----------------------------------------------------------------
% Label and count connected components
[L Ne] = bwlabel(imgn);
for n=1:Ne
[r,c] = find(L==n);
% Extract letter
n1=imgn(min(r):max(r),min(c):max(c));
% Resize letter (same size of template)
img_r=imresize(n1,[42 24]);
%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
%fprintf(fid,'%s\n',lower(word));%Write 'word' in text file
(lower)
fprintf(fid,'%s\n',word);%Write 'word' in text file (upper)
% Clear 'word' variable
word=[ ];
if isempty(re) %See variable 're' in Fcn 'lines'
break
end
end
fclose(fid);
%Open 'text.txt' file
winopen('text.txt')
sample image is http://imgur.com/Ajmsi
FIR
FIR on 22 Oct 2011
http://imgur.com/YHYFD and for this image also in need to extract score

Sign in to comment.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!