I have created templates of number and symbols and want to match the vehicle number plate with template using corr2 function. While running the code got the following error
Error using corr2Expected input number 1, A, to be two-dimensional.
MAtlab code for template creation
%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
matlab code for reading the letter
load NewTemplates1 % Loads the templates of characters in the memory.
snap=imread('untitled.png');snap=imresize(snap,[42 24]); % Resize the input image so it can be compared with the template's images.
comp=[ ];for n=1:length(NewTemplates1) sem=corr2(NewTemplates1{1,n},snap); % Correlation the input image with every image in the template for best matching.
comp=[comp sem]; % Record the value of correlation for each template's character.
endvd=find(comp==max(comp)); % Find the index which correspond to the highest matched character.
%*-*-*-*-*-*-*-*-*-*-*-*-*-
% Accodrding to the index assign to 'letter'.
% Alphabets listings.
if vd==1 letter='1';elseif vd==2 letter='2';elseif vd==3 letter='3';elseif vd==4 letter='4';elseif vd==5 letter='5';elseif vd==6 letter='0';elseif vd==7 letter='sign';end
For kind information: The size of individual component in template is 42x24x3 uint8 and the input image also same dimension. Please provide the suggestion to do further.
Best Answer