sketch recognition

I AM USING THIS PROGRAM FOR SKETCH RECOGNITION HOWEVER IT IS GIVING ME THE ERROR ??? Subscripted assignment dimension mismatch.
Error in ==> sym_rec_main2 at 60 I3Dtotal(:,:,2) = Ibw3D2;
WHAT AM I DOING WRONG?
I3D1 = imread('IMG_0001.jpg');
I3D2 = imread('IMG_0002.jpg');
I3D3 = imread('IMG_0003.jpg');
I3D4 = imread('IMG_0004.jpg');
size3Dr = input('Enter number of training sets');
size3Dc = input('Enter number of different symbols');
sizer = size3Dr; %Assuming equal traning sets
sizec = size3Dc;
noimages = sizer/6;
Igray1 = rgb2gray(I3D1);
Ibw3D1 = im2bw(Igray1,graythresh(Igray1));
Igray2 = rgb2gray(I3D2);
Ibw3D2 = im2bw(Igray2,graythresh(Igray2));
Igray3 = rgb2gray(I3D3);
Ibw3D3 = im2bw(Igray3,graythresh(Igray3));
Igray4 = rgb2gray(I3D4);
Ibw3D4 = im2bw(Igray3,graythresh(Igray4));
I3Dtotal(:,:,1) = Ibw3D1;
I3Dtotal(:,:,2) = Ibw3D2;
I3Dtotal(:,:,3) = Ibw3D3;
I4Dtotal(:,:,3) = Ibw3D4;
rfactor = 1; crpval = 0;
for i = 1 : noimages
I = I3Dtotal(:,:,i);
img = sym_rec_img_preprocess(I, size3Dr, size3Dc, noimages);
for cnt = 1:((size3Dr*size3Dc)/noimages)
bw2 = img_crop(img{cnt}, rfactor, crpval);
charvec = img_resize(not(bw2));
out3D(:,cnt,i) = charvec;
end
end

Respuestas (2)

Walter Roberson
Walter Roberson el 6 de Abr. de 2011

0 votos

Use size() to check that all of the I3D* image arrays are the same size.

5 comentarios

stephanie borg
stephanie borg el 6 de Abr. de 2011
NO THEY'RE NOT EXACTLY EQUAL BUT CLOSE. COULD THAT BE THE ERROR? HOW CAN I ARRANGE THEM TO BE THE SAME?
Walter Roberson
Walter Roberson el 6 de Abr. de 2011
You can prevent the error by using code like this:
maxdims = max([size(Ibw3D1); size(Ibw3D2); size(Ibw3D3); size(Ibw3D4)]);
I3Dtotal = zeros([maxdims(1), maxdims(2), 4], class(Ibw3D4));
I3Dtotal(1:size(Ibw3D1,1),1:size(Ibw3D1,2),1) = Ibw3D1;
I3Dtotal(1:size(Ibw3D2,1),1:size(Ibw3D2,2),1) = Ibw3D2;
I3Dtotal(1:size(Ibw3D3,1),1:size(Ibw3D3,2),1) = Ibw3D3;
I3Dtotal(1:size(Ibw3D4,1),1:size(Ibw3D4,2),1) = Ibw3D4;
This will use zeros in the locations where the arrays were smaller.
Alternately, you could use,
mindims = min([size(Ibw3D1); size(Ibw3D2); size(Ibw3D3); size(Ibw3D4)]);
and then you could
Ibw3D1 = imresize(Ibw3D1,mindims);
Ibw3D2 = imresize(Ibw3D2,mindims);
and so on, after which you could use your existing Ibwtotal code. This would not use zero padding anywhere, but would have the disadvantage of interpolating some of the arrays to fit the smallest size which will introduce artifacts. (You could resize to maxdims instead of mindims if you wanted.)
stephanie borg
stephanie borg el 6 de Abr. de 2011
CAN I PLEASE TALK TO YOU ON YOUR PERSONAL EMAIL? THANKS
Walter Roberson
Walter Roberson el 6 de Abr. de 2011
It is 07:00 here and I am going to bed in a moment. It is better to post your questions as others may be able to answer them. Especially if they are questions about the sketch recognition portion, as I am not familiar with the techniques used for sketch recognition.
stephanie borg
stephanie borg el 6 de Abr. de 2011
ok i understand. because this program is supposed to work. im afraid i have something wrong in the sketches but i dont know.

Iniciar sesión para comentar.

Tim Zaman
Tim Zaman el 6 de Abr. de 2011

0 votos

The images you are using in this code have to be the exact amount of pixels: so if image 1 is 800x600, image 2 has to be 800x600 too. Common error with image processing.

2 comentarios

stephanie borg
stephanie borg el 6 de Abr. de 2011
you're right! they're not the same.. do you know from where i can change that? thanks
Walter Roberson
Walter Roberson el 6 de Abr. de 2011
You could use the imresize() suggestion I made earlier. You will have to decide whether you want to size the small images up, or the larger images down.

Iniciar sesión para comentar.

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Abr. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by