Getting an error as "??? Error using ==> horzcat CAT arguments dimensions are not consistent" in the offline signature verification code below.
1 view (last 30 days)
Show older comments
Suresh Matyal
on 28 Nov 2013
Commented: Suresh Matyal
on 6 Aug 2014
In this error found in offline signature verification system code, when iam comparing a scaned signature image to the database image, the relative code will be as follows..
Error code:
function [aspect_ratio ,abs_height1 , abs_width ,gri_featu, z4]=create_template(namefile,pathname)
% function [cx,cy] =normal(j1,x,y);
% j=imread('D:\ProgramC\matlab\SIG_WORK\image\user10_image.bmp');
% j=imresize(j,[256 400]);
% j=fc(end:2:1,end:2:1);
namefile1=[pathname namefile];
j = imread(namefile1);
figure,imshow(j);
% p=logical(j);
[x,y]=size(j);
r_one=ones(x,10).*256;
c_one=ones(10,y+10).*256;
j=[r_one,j]; %mainly error found in this line
j=[c_one;j];
[x,y]=size(j);
figure,imshow(j);
% r_one=ones(x,1).*256;
% c_one=ones(1,y+1).*256;
% j=[r_one,j];
% j=[c_one;j];
cx=x/2;
cy=y/2;
h=[cx,cy];
% xmean=double(sum(sum(j(cx,:))))/cy
% ymean=double(sum(sum(j(:,cy))))/cx
% p=j(cx,:)
% v=p(:)-xmean
% summa1=0;
% for i=1:1:y
% summa1=summa1+((j(cx,:)-xmean)).^2
% end
v=j(round(cx),:);
% m=double(v(cy:y));
xmean=sum(v(:))/y;
% l2=m(:);
% l3=length(l2);
v1=j(:,round(cy));
% m1=double(v1(cx:x));
% l4=length(m1);
ymean=double(sum(v1(:))/x);
p=double(v-xmean);
p1=p().^2;
summa1=0;
for i=1:1:y
summa1=summa1+p1(i);
end
t1=summa1;
j1=double(v1-ymean);
u=zeros(y-x,1);
j1=[j1;u];
p2=j1().^2;
summa2=0;
for d=1:1:x
summa2=summa2+p2(d);
end
t2=summa2;
q0=p(:).*j1;
summa3=0;
for q=1:1:y
summa3=summa3+q0(q);
end
t3=summa3;
k1=acosd((1/(2^0.5))*(abs(1+(t1-t2))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k2=acosd(-(1/(2^0.5))*(abs(1+(t1-t2))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k3=-acosd((1/(2^0.5))*(abs(1+(t1-t2))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k4=-acosd(-(1/(2^0.5))*(abs(1+(t1-t2))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k5=acosd((1/(2^0.5))*(abs(1+(t2-t1))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k6=acosd(-(1/(2^0.5))*(abs(1+(t2-t1))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k7=-acosd((1/(2^0.5))*(abs(1+(t2-t1))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
k8=-acosd(-(1/(2^0.5))*(abs(1+(t2-t1))/(t1^2+4*t3^2-2*t1*t2+t2^2)^0.5)^0.5);
f1=(cos(angle(k1)))^2*t1+2*cos(angle(k1))*sin(angle(k1))*t3+(sin(angle(k1)))^2*t2;
f2=(cos(angle(k2)))^2*t1+2*cos(angle(k2))*sin(angle(k2))*t3+(sin(angle(k2)))^2*t2;
f3=(cos(angle(k3)))^2*t1+2*cos(angle(k3))*sin(angle(k3))*t3+(sin(angle(k3)))^2*t2;
f4=(cos(angle(k4)))^2*t1+2*cos(angle(k4))*sin(angle(k4))*t3+(sin(angle(k4)))^2*t2;
f5=(cos(angle(k5)))^2*t1+2*cos(angle(k5))*sin(angle(k5))*t3+(sin(angle(k5)))^2*t2;
f6=(cos(angle(k6)))^2*t1+2*cos(angle(k6))*sin(angle(k6))*t3+(sin(angle(k6)))^2*t2;
f7=(cos(angle(k7)))^2*t1+2*cos(angle(k7))*sin(angle(k7))*t3+(sin(angle(k7)))^2*t2;
f8=(cos(angle(k8)))^2*t1+2*cos(angle(k8))*sin(angle(k8))*t3+(sin(angle(k8)))^2*t2;
if (f1>=f3&f1>=f2&f1>=f4&f1>=f5&f1>=f6&f1>=f7&f1>=f8)
if(k1<k2&k1<k3&k1<k4&k1<k6&k1<k7&k1<k8)
l0=[cosd(angle(k1)) sind(angle(k1)) 0
-sind(angle(k1)) cosd(angle(k1)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
figure,imshow(transformedim);
% % else
% l0=[cosd(angle(k2)) sind(angle(k2)) 0
% -sind(angle(k2)) cosd(angle(k2)) 0
% 0 0 1];
%trform=maketform('affine',l0)
%
%tformfwd([cx cy],trform);
%transformedim=imtransform(j,trform);
%figure,imview(transformedim);
end
end
if (f2>=f3&f2>=f1&f2>=f4&f2>=f5&f2>=f6&f2>=f7&f2>=f8)
if (k2<k1&k2<k3&k2<k4&k2<k5&k2<k7&k2<k8)
l0=[cosd(angle(k2)) sind(angle(k2)) 0
-sind(angle(k2)) cosd(angle(k2)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
figure,imshow(transformedim);
end
end
% % % else
% l0=[cosd(angle(k4)) sind(angle(k4)) 0
% -sind(angle(k4)) cosd(angle(k4)) 0
% 0 0 1];
% trform=maketform('affine',l0)
%
% tformfwd([cx cy],trform);
% transformedim=imtransform(j,trform);
% figure,imview(transformedim);
% % % end
% % % end
if(f3>=f2&f3>=f1&f3>=f4&f3>=f5&f3>=f6&f3>=f7&f3>=f8)
if (k3<k2&k3<k1&k3<k4&k3<k5&k3<k6&k3<k8)
l0=[cosd(angle(k3)) sind(angle(k3)) 0
-sind(angle(k3)) cosd(angle(k3)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
figure,imshow(transformedim);
end
end
% % % else
% % % l0=[cosd(angle(k6)) sind(angle(k6)) 0
% % % -sind(angle(k6)) cosd(angle(k6)) 0
% % % 0 0 1];
% % % trform=maketform('affine',l0)
% % %
% % % tformfwd([cx cy],trform);
% % % transformedim=imtransform(j,trform);
% % % figure,imview(transformedim);
% % % end
% % % end
if (f4>=f2&f4>=f1&f4>=f3&f4>=f5&f4>=f6&f4>=f7&f4>=f8)
if (k4<k2&k4<k3&k4<k5&k4<k6&k4<k7&k4<k1)
l0=[cosd(angle(k4)) sind(angle(k4)) 0
-sind(angle(k4)) cosd(angle(k4)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
% figure,imview(transformedim);
end
end
if (f5>=f2&f5>=f1&f5>=f3&f5>=f4&f5>=f6&f5>=f7&f5>=f8)
if (k5<k2&k5<k3&k5<k4&k5<k6&k5<k7&k5<k8)
l0=[cosd(angle(k5)) sind(angle(k5)) 0
-sind(angle(k5)) cosd(angle(k5)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
% figure,imview(transformedim);
end
end
if (f6>=f2&f6>=f1&f6>=f3&f6>=f4&f6>=f5&f6>=f7&f6>=f8)
if (k6<k1&k6<k3&k6<k4&k6<k5&k6<k7&k6<k8)
l0=[cosd(angle(k6)) sind(angle(k6)) 0
-sind(angle(k6)) cosd(angle(k6)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
% figure,imview(transformedim);
end
end
if (f7>=f2&f7>=f1&f7>=f3&f7>=f4&f7>=f5&f7>=f6&f7>=f8)
if (k7<k1&k7<k2&k7<k4&k7<k5&k7<k6&k7<k8)
l0=[cosd(angle(k7)) sind(angle(k7)) 0
-sind(angle(k7)) cosd(angle(k7)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
% figure,imview(transformedim);
end
end
if (f8>=f2&f8>=f1&f8>=f3&f8>=f4&f8>=f5&f8>=f7&f8>=f6)
if (k8<k1&k8<k3&k8<k2&k8<k5&k8<k7&k8<k6)
l0=[cosd(angle(k8)) sind(angle(k8)) 0
-sind(angle(k8)) cosd(angle(k8)) 0
0 0 1];
trform=maketform('affine',l0);
tformfwd([cx cy],trform);
transformedim=imtransform(j,trform);
% figure,imview(transformedim);
end
end
figure,imshow(transformedim);
h01=double(transformedim);
% h1=houghl(h01);
% figure(4),imshow(h1,[]);
[h0,t]=edge(transformedim,'roberts',0.00001,'horizontal');
h1= im2double(h0);
h2=fspecial('gaussian',2,15);
h3=imfilter(h1,h2,'replicate');
h4=im2bw(h1,0.00001*graythresh(h3));
fth=bwmorph(h4,'skel',5);
% z1=skelztn(h4);
% fth=bwmorph(h4,'thin',inf);
z2=double(imcomplement(fth));
z3=h01()-z2();
z3=logical(z3);
z4=bwmorph(z3,'spur',inf);
z4=mat2gray(double(z4));
z4(:,2:12)=[];
z4(1:23,:)=[];
[x1,y1]=size(z4);
% se=strel('disk',1);
% fo=imopen(z4,se);
% fclo=imclose(fo,se);
% z1=skelztn(z3);
% z4=xor(z1,z3);
figure,imshow(z4);
% z5=cutboarder(z4);
% figure(6),imview(z5);
%
% z7=cooccurencemat(z4,2,-1,0);
%%%%%%***GlobalFeatures***%%%%%%%%%
for i1=1:1:x1
for d1=1:1:y1
if z4(i1,d1)==0
s1=i1;
r1=d1;
break
end
end
end
for i2=x1:-1:1
for d2=1:1:y1
if z4(i2,d2)==0
s2=i2;
r2=d2;
break;
end
end
end
height=s1-s2;
for d3=1:1:y1
for i3=1:1:x1
if z4(i3,d3)==0
s3=d3;
r3=i3;
break
end
end
end
for d4=y1:-1:1
for i4=1:1:x1
if z4(i4,d4)==0
s4=d4;
r4=i4;
break
end
end
end
width_norma=s3-s4;
aspect_ratio=height/width_norma;
sum_z4=sum(sum(z4));
black_area=(x1*y1)-sum_z4;
count=0;
for c1=s2:1:x1
if z4(c1,r2)==0
count=count+1;
end
end
abs_height1=count;
count1=0;
for c2=s3:1:y1
if z4(r3,s3)==0
count1=count1+1;
end
end
abs_width=count1;
% z7=cooccurencemat(z4,4,1,0);
% **** grid features********
j=logical(j);
fs1=j(1:x/2,:);
fs2=j(:,1:y/2);
[xf1,yf1]=size(fs1);
sum_fs1=sum(sum(fs1));
no_black1=(xf1*yf1)-sum_fs1;
% Fs2=J(:,1:Y/2);
[xf2,yf2]=size(fs2);
sum_fs2=sum(sum(fs2));
no_black2=(xf2*yf2)-sum_fs2;
fs3=fs1(1:xf1/2,:);
[xf3,yf3]=size(fs3);
sum_fs3=sum(sum(fs3));
no_black3=(xf3*yf3)-sum_fs3;
fs4=fs1(:,1:yf1/2);
[xf4,yf4]=size(fs4);
sum_fs4=sum(sum(fs4));
no_black4=(xf4*yf4)-sum_fs4;
fs5=fs2(1:xf2/2,:);
[xf5,yf5]=size(fs5);
sum_fs5=sum(sum(fs5));
no_black5=(xf5*yf5)-sum_fs5;
fs6=fs2(:,1:yf2/2);
[xf6,yf6]=size(fs6);
sum_fs6=sum(sum(fs6));
no_black6=(xf6*yf6)-sum_fs6;
fs7=fs3(1:xf3/2,:);
[xf7,yf7]=size(fs7);
sum_fs7=sum(sum(fs7));
no_black7=(xf7*yf7)-sum_fs7;
fs8=fs3(:,1:yf3/2);
[xf8,yf8]=size(fs8);
sum_fs8=sum(sum(fs8));
no_black8=(xf8*yf8)-sum_fs8;
fs9=fs4(1:xf4/2,:);
[xf9,yf9]=size(fs9);
sum_fs9=sum(sum(fs9));
no_black9=(xf9*yf9)-sum_fs9;
fs10=fs4(:,1:yf4/2);
[xf10,yf10]=size(fs10);
sum_fs10=sum(sum(fs10));
no_black10=(xf10*yf10)-sum_fs10;
gri_featu=[no_black1,no_black2,no_black3,no_black4,no_black5,no_black6,no_black7,no_black8,no_black9,no_black10];
clc;
% save('template file', 'aspect_ratio','abs_height1','abs_width','gri_featu','z4')
1 Comment
Walter Roberson
on 29 Nov 2013
Which line is the problem occurring on? What are the size() of each variable involved in the expression?
Why is that glob of code at the end not written in terms of cell arrays?
Accepted Answer
Walter Roberson
on 29 Nov 2013
The image is probably being received as an RGB image, which would be 3 dimensional. You are then trying to combine it with a 2 dimensional variable.
I suggest that you should use
j = rgb2gray(j);
just before your line
[x,y]=size(j);
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!