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

 Respuesta aceptada

Siddharth Mallya
Siddharth Mallya el 16 de Mzo. de 2011

0 votos

Got the answer. The character set my mates gave me were 3D and I am using an 2D matrix

Más respuestas (1)

Matt Fig
Matt Fig el 16 de Mzo. de 2011

1 voto

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 comentarios

Jan
Jan el 16 de Mzo. de 2011
Thanks, Matt, for posting the simplificated version. It supports the rule of thumb: "Less commands, less bugs".
Matt Fig
Matt Fig el 16 de Mzo. de 2011
I thought you were being poetic, perhaps mixing German and English, with:
"Lett..."
Siddharth Mallya
Siddharth Mallya el 16 de Mzo. de 2011
@Matt,
clc;
T = char([97:122 48:57]);
for ii = 1:length(T)
init = imread(['CharacterSet\',T(ii),'.bmp']);
init = rgb2ind(init,2);
imwrite([24 42], '[CharacterSet\',T(ii), 'bmp');
end
I am trying to convert my 3D images to 2D using this .. but it just isn't seeming to work. I get this error -->
??? Error using ==> imwrite at 376
Unable to determine the file format from the filename.
Error in ==> convert at 6
imwrite([24 42], '[CharacterSet\',T(ii), 'bmp');
Matt Fig
Matt Fig el 16 de Mzo. de 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
Siddharth Mallya el 16 de Mzo. de 2011
Okay, I added a line saying,
B = zeros ([24 42]);
for ----
...
IMWRITE (B, '[CharacterSet\',T(ii), 'bmp');
...
still doesn't work .. =/
Matt Fig
Matt Fig el 16 de Mzo. de 2011
You are missing a ]. You have:
'[CharacterSet\',T(ii)
but you should have:
['CharacterSet\',T(ii),'.bmp']
Siddharth Mallya
Siddharth Mallya el 17 de Mzo. de 2011
Ya .. No. I made a mistake while typing it here. The error I get is this exactly,
Error using ==> imwrite at 394
Cannot open $#^#$% file for writing
You may not have write permission

Iniciar sesión para comentar.

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by