Error in horzcat
Ältere Kommentare anzeigen
Hey ! I am trying to make a template of my braille character set and I keep getting the following error. I used the same code for OCR and it works perfectly. What do I do ?
I am attaching the code herewith,
%Letter
A=imread('CharacterSet\a.bmp');B=imread('CharacterSet\b.bmp');
C=imread('CharacterSet\c.bmp');D=imread('CharacterSet\d.bmp');
E=imread('CharacterSet\e.bmp');F=imread('CharacterSet\f.bmp');
G=imread('CharacterSet\g.bmp');H=imread('CharacterSet\h.bmp');
I=imread('CharacterSet\i.bmp');J=imread('CharacterSet\j.bmp');
K=imread('CharacterSet\k.bmp');L=imread('CharacterSet\l.bmp');
M=imread('CharacterSet\m.bmp');N=imread('CharacterSet\n.bmp');
O=imread('CharacterSet\o.bmp');P=imread('CharacterSet\p.bmp');
Q=imread('CharacterSet\q.bmp');R=imread('CharacterSet\r.bmp');
S=imread('CharacterSet\s.bmp');T=imread('CharacterSet\t.bmp');
U=imread('CharacterSet\u.bmp');V=imread('CharacterSet\v.bmp');
W=imread('CharacterSet\w.bmp');X=imread('CharacterSet\x.bmp');
Y=imread('CharacterSet\y.bmp');Z=imread('CharacterSet\z.bmp');
%Number
one=imread('CharacterSet\1.bmp'); two=imread('CharacterSet\2.bmp');
three=imread('CharacterSet\3.bmp');four=imread('CharacterSet\4.bmp');
five=imread('CharacterSet\5.bmp'); six=imread('CharacterSet\6.bmp');
seven=imread('CharacterSet\7.bmp');eight=imread('CharacterSet\8.bmp');
nine=imread('CharacterSet\9.bmp'); zero=imread('CharacterSet\0.bmp');
letter=[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z];
number=[one two three four five six seven eight nine zero];
character=[letter number];
templates=mat2cell(character,42,[24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 24]);
save ('templates','templates')
clear all
What is the problem ? =O
Akzeptierte Antwort
Weitere Antworten (1)
Matt Fig
am 16 Mär. 2011
It would really help if you indicated which line errors, as I am sure you could guess if you put yourself in our shoes - but anyway...
If the error is on the line which assigns 'letter', then at least one of your CharacterSet images is not the same size as the others.
If the error is on the line which assigns 'number', then at least one of your CharacterSet images is not the same size as the others.
If the error is on the line which assigns 'character', then perhaps the 'letter' and 'number' variables aren't the same size.
.
.
By the way, you could do something much easier, like this:
T = char([97:122 48:57]);
templates = cell(1,length(T));
for ii = 1:length(T)
templates{ii} = imread(['CharacterSet\',T(ii),'.bmp']);
end
7 Kommentare
Jan
am 16 Mär. 2011
Thanks, Matt, for posting the simplificated version. It supports the rule of thumb: "Less commands, less bugs".
Matt Fig
am 16 Mär. 2011
I thought you were being poetic, perhaps mixing German and English, with:
"Lett..."
Siddharth Mallya
am 16 Mär. 2011
Matt Fig
am 16 Mär. 2011
I think you are using IMWRITE incorrectly. I cannot try it out because I don't have rgb2ind, but if this function returns a 2D matrix, then you need to tell IMWRITE to save it in some form of image that is 2D. Look at the help for IMWRITE to see the correct usage.
Siddharth Mallya
am 16 Mär. 2011
Matt Fig
am 16 Mär. 2011
You are missing a ]. You have:
'[CharacterSet\',T(ii)
but you should have:
['CharacterSet\',T(ii),'.bmp']
Siddharth Mallya
am 17 Mär. 2011
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!