Error in horzcat
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Matt Fig
2011 年 3 月 16 日
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 件のコメント
Jan
2011 年 3 月 16 日
Thanks, Matt, for posting the simplificated version. It supports the rule of thumb: "Less commands, less bugs".
Matt Fig
2011 年 3 月 16 日
I thought you were being poetic, perhaps mixing German and English, with:
"Lett..."
Siddharth Mallya
2011 年 3 月 16 日
Matt Fig
2011 年 3 月 16 日
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
2011 年 3 月 16 日
Matt Fig
2011 年 3 月 16 日
You are missing a ]. You have:
'[CharacterSet\',T(ii)
but you should have:
['CharacterSet\',T(ii),'.bmp']
Siddharth Mallya
2011 年 3 月 17 日
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!