ERROR READING SPECIAL CHARACTER USING OCR

6 visualizzazioni (ultimi 30 giorni)
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 Commenti
FIR
FIR il 24 Ott 2011
walter please answer for my question
Jan
Jan il 24 Ott 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.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Ott 2011
"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 Commenti
Image Analyst
Image Analyst il 24 Ott 2011
I think I'd like to see that. Could be fun.
Walter Roberson
Walter Roberson il 24 Ott 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.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 24 Ott 2011
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.

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by