error in template creation

2 visualizaciones (últimos 30 días)
SHOBA MOHAN
SHOBA MOHAN el 11 de En. de 2018
Comentada: SHOBA MOHAN el 15 de En. de 2018
I wish to create template of number and sign to extract the vehicle number plate. I got loading error
"Dimensions of matrices being concatenated are not consistent".
% Create Templates
one=imread('1.png'); two=imread('2.png');
three=imread('3.png');four=imread('4.png');
five=imread('5.png');
zero=imread('0.png');
sign=imread('sign.png');
number=[one two three four five zero ];
character=[number sign];
NewTemplates1=mat2cell(character,7,[24 24 24 24 24 24 24]);
save ('NewTemplates1','NewTemplates1')
clear all
can anyone help me to resolve this?

Respuesta aceptada

SHOBA MOHAN
SHOBA MOHAN el 14 de En. de 2018
Thanks Guillaume !!!!!. I am able to create template of sign and symbol using the following code
%CREATE TEMPLATES
one=imread('1.png');
one=imresize(one,[42 24]);
two=imread('2.png');
two=imresize(two,[42 24]);
three=imread('3.png');
three=imresize(three,[42 24]);
four=imread('4.png');
four=imresize(four,[42 24]);
five=imread('5.png');
five=imresize(five,[42 24]);
zero=imread('0.png');
zero=imresize(zero,[42 24]);
sign=imread('sign.png');
sign=imresize(sign,[42 24]);
number=[one two three four five zero ];
character=[number sign];
NewTemplates1=mat2cell(character,42,[24 24 24 24 24 24 24], 3);
save ('NewTemplates1','NewTemplates1')
clear all
  2 comentarios
Guillaume
Guillaume el 15 de En. de 2018
Editada: Guillaume el 15 de En. de 2018
Note: there's no point concatenating all the images into a matrix to then split them back up into a cell array. You can just put them straight into the cell array. Instead of
number = ...
character = ...
NewTemplates1 = ...
just
NewTemplates = {one two three four five zero sign};
Also, once you start writing more or less the same code several times it's a good indication that a loop would work better. You coud simplify the whole code to:
desiredsize = [42 24];
files = {'1', '2', '3', '4', '5', '0', 'sign'};
NewTemplates1 = cell(size(files));
for fileidx = 1:numel(files)
img = imread([files{fileidx}, '.png']);
img = imresize(img, desiredsize);
NewTemplates1{fileidx} = img;
end
SHOBA MOHAN
SHOBA MOHAN el 15 de En. de 2018
Thanks Guillaume. I included rgb2gray in the given code to make suitable for further processing (i.e. correlation and median filtering).
desiredsize = [42 24];
files = {'1', '2', '3', '4', '5', '0', 'sign'};
NewTemplates1 = cell(size(files));
for fileidx = 1:numel(files)
img = imread([files{fileidx}, '.png']);
img = rgb2gray(img);
img = imresize(img, desiredsize);
NewTemplates1{fileidx} = img;
end

Iniciar sesión para comentar.

Más respuestas (1)

Guillaume
Guillaume el 11 de En. de 2018
Your code tries to concatenates the images side by side but at least one of the images is not the same height as the others or is grayscale or indexed while the others are RGB. Hence the concatenation is not possible.
You can resolve this in many way:
  • concatenate images that are the same height and colour format
  • resize your images after loading them so they're all the same height
  • pad the smaller images (with black? white?)
It's all up to you.
  1 comentario
SHOBA MOHAN
SHOBA MOHAN el 14 de En. de 2018
I am resized the images but getting the following error
Number of input vector arguments, 2, does not match the input matrix's number of dimensions, 3.
This is the following code:
%CREATE TEMPLATES
one=imread('1.png');
one=imresize(one,[42 24]);
two=imread('2.png');
two=imresize(two,[42 24]);
three=imread('3.png');
three=imresize(three,[42 24]);
four=imread('4.png');
four=imresize(four,[42 24]);
five=imread('5.png');
five=imresize(five,[42 24]);
zero=imread('0.png');
zero=imresize(zero,[42 24]);
sign=imread('sign.png');
sign=imresize(sign,[42 24]);
number=[one two three four five zero ];
character=[number sign];
NewTemplates1=mat2cell(character,7,[24 24 24 24 24 24 24]);
save ('NewTemplates1','NewTemplates1')
clear all
please help me on this issue

Iniciar sesión para comentar.

Categorías

Más información sobre Geometric Transformation and Image Registration en Help Center 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