difficult in reading special characters
Show older comments
I find difficult in writing in text pad,which is last line,while writing numbers and special characters,it displays wrong result
foe ex IND 77-4 IT DISPLAY AS IND 7Zm
samp22.jpg is my input file,the image has content IND 77-4
clc, close all, clear all
% Read image
imagen=imread('samp22.jpg');
% Show image
imagen1 = imagen;
figure,imshow(imagen1);
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);
imagen2 = imagen;
figure,imshow(imagen2);
% title('before bwareaopen')
% Remove all object containing fewer than 15 pixels
imagen = bwareaopen(imagen,15);
imagen3 = imagen;
%figure,imshow(imagen3);
%title('after bwareaopen')
%Storage matrix word from image
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_crop' separate lines in text
[fl re]=lines_crop(re); %fl= first line, re= remaining image
imgn=fl;
n=0;
%Uncomment line below to see lines one by one
%figure,imshow(fl);pause(2)
%-----------------------------------------------------------------
spacevector = []; % to compute the total spaces betweeen
% adjacent letter
rc = fl;
while 1
%Fcn 'letter_crop' separate letters in a line
[fc rc space]=letter_crop(rc); %fc = first letter in the line
%rc = remaining cropped line
%space = space between the letter
% cropped and the next letter
%uncomment below line to see letters one by one
figure,imshow(fc);pause(0.5)
img_r = imresize(fc,[42 24]); %resize letter so that correlation
%can be performed
n = n + 1;
spacevector(n)=space;
%Fcn 'read_letter' correlates the cropped letter with the images
%given in the folder 'letters_numbers'
letter = read_letter(img_r,num_letras);
%letter concatenation
word = [word letter];
if isempty(rc) %breaks loop when there are no more characters
break;
end
end
%-------------------------------------------------------------------
%
max_space = max(spacevector);
no_spaces = 0;
for x= 1:n %loop to introduce space at requisite locations
if spacevector(x+no_spaces)> (0.75 * max_space)
no_spaces = no_spaces + 1;
for m = x:n
word(n+x-m+no_spaces)=word(n+x-m+no_spaces-1);
end
word(x+no_spaces) = ' ';
spacevector = [0 spacevector];
end
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=[ ];
%*When the sentences finish, breaks the loop
if isempty(re) %See variable 're' in Fcn 'lines'
break
end
end
fclose(fid);
%Open 'text.txt' file
winopen('text.txt')
6 Comments
Jan
on 20 Sep 2011
@Pat: Your code is not readable. This is yout 47th question, so I expect that you are familiar with the conventions in this forum. If not, follow the "Markup help"-lin on this page to lear about formatting the question.
Your questions concern these topic:
1. Accurate Cancer Classification Using Expressions of Very Few Genes
2. Fuzzy logic methods for "linguistic variables".
3. compression of images using 3d-iwt
4. 3-D Scalable Medical Image Compression With Optimized Volume of Interest Coding" using "Modified EBCOT"
5. Finger print recognisation, Gabor filtering
6. Reading scorecards in video mining and using OCR methods to identify numbers.
7. Calculation of accuracy for 5 fold cross validation.
Most of your questions cannot be answered, because they do not contain the necessary information. You've posted question repeatedly instead of responding to questions for clarifications. You've accepted only 15% of the answers, and even then you proceed to ask further questions in the comment sections. And all this happened in the last 21 days.
It seems like you are working on too many problems at the same time, such that it is hard to keep the overview. Using this forum will be much more efficient, if you concentrate on one problem after the other and care for an existing thread until it is solved completely. Then accept the final answer.
With your current style of posting I got the impression, that you have a confused working style and spending time to create a meaningful answer is a bad investment.
Pat
on 20 Sep 2011
Jan
on 20 Sep 2011
I suggest starting with formatting the code of this question.
Pat
on 20 Sep 2011
Grzegorz Knor
on 20 Sep 2011
markup help:
http://www.mathworks.com/matlabcentral/answers/help/markup
Pat
on 20 Sep 2011
Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!