ERROR READING SPECIAL CHARACTER USING OCR

walter i have posted the code for reference of OCR
% 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
http://imgur.com/YHYFD and for this image also in need to extract score

4 comentarios

Jan
Jan el 24 de Oct. de 2011
This is your 38th question. Yozu should know how to format the code now. Please spend the time to improve the readability. If you are in doubt, follow the "Markup help" link on this page again.
For the "clear all" see: http://www.mathworks.com/matlabcentral/answers/16484-good-programming-practice#answer_22301
There is a missing parenthesis in the "title('INPUT IMAGE...'" line.
We cannot guess the contents of "load templates; global templates".
As far as I remember your problem is the wrong recognition of characters. Then the shown program is not interesting, because the problem appears in the function "read_letter".
Finally this message does not contain a question anymore. If you reference another question, it would be better to insert the code there or add at least a link to the original question.
FIR
FIR el 24 de Oct. de 2011
http://www.mathworks.com/matlabcentral/answers/18965-error-in-reading-special-characters
here is the link ..........i want to extract the score and write that score into note papad,at least it must be diaplayed in command window
i have uploaded two images ....
want to read only the scores
FIR
FIR el 24 de Oct. de 2011
walter please answer for my question
Jan
Jan el 24 de Oct. de 2011
@FIR: Did you read my comment?
Is there a reason not to apply a proper code formatting? Bad formatted code provokes the impression, that you do not care about the readability of your question.
I've mentioned, that the problems occur in a part of the code, which you did not post: "letter=read_letter(img_r, num_letras);". Therefore answering requires wild guessing.
If you have problems with your code, "warning off" is a very bad idea. You want support of this forum, but reject the help of your local Matlab.
Please, FIR, post the relevant code using a proper formatting: Let MATLAB's editor auto-indent the code, copy it, paste it here, mark it with the mouse and hit the "{} code" button.

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 24 de Oct. de 2011

0 votos

"walter please answer for my question "
Well, FIR, I do need more than 6 hours of sleep per night, so unless you want my response to be a transcription of one of my dreams, you will need to wait.

2 comentarios

Image Analyst
Image Analyst el 24 de Oct. de 2011
I think I'd like to see that. Could be fun.
Walter Roberson
Walter Roberson el 24 de Oct. de 2011
"I find myself taking programming classes at U. Waterloo, dealing with a programming language named 'MATLOG', a PROLOG derivative. And I keep arguing in class with the professor, who keeps making fundamental mistakes in the language. The professor has a bunch of hand-written notes he wrote, photocopied and distributed to class as being "the" textbook for the course; he just hasn't had time yet to formally publish it but what we are dealing with is intended to go on to be the standard student reference work for later years. And he keeps making mistake after mistake, and I keep correcting him, and of course he keeps claiming that his version is correct and he knows that because he wrote the book himself! But I happen to have a copy of the first edition design documents for the language, and the third edition "report" on the language, *and* these issues we argue about are ones that are easily resolvable by running a couple of test cases through the standard compiler for the language which was written by an earlier generations of U. Waterloo grad students. My interpretations are correct and his are outright wrong, but he refuses to admit it, and keeps docking me marks for not doing things his way (oh, and for continually arguing) even though his way would result in incorrect answers and all those students being taught misunderstandings of important computing concepts. I find I am not doing very well in the class because of this, only getting about a 73% average even all of my assignments run without bugs, and even though in (dream) fact I am qualified to edit the mistakes in his proto-textbook and rewrite large sections of it.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 24 de Oct. de 2011

0 votos

Yes, I see you did, as you had already posted in the active question.
In my time zone, it is presently 2 AM, and you posted sometime after 1 AM here, which was after the last time I checked Answers for the evening at 12:55 AM. I am not going to look at this code at the present time: I need sleep.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Preguntada:

FIR
el 24 de Oct. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by