www.pudn.com > zishiyingjiami.rar > testPair.m, change:2011-12-27,size:1077b


function P=testPair(A,B) 
%得到明文A,密文B相邻像素之间的相关性,并作图表示明文和密文水平像素间的相关性 
 
[U,V]=randPair(A,'horizental',1000); 
hA=ccoef(U,V) 
%plot the correlation of the plain 
figure(1),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x,y+1)处的像素值'); 
[U,V]=randPair(B,'horizental',1000); 
hB=ccoef(U,V) 
%plot the correlation of the cipher 
figure(2),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x+1,y+1)处的像素值'); 
 
[U,V]=randPair(A,'vertical',1000); 
vA=ccoef(U,V) 
figure(3),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x+1,y)处的像素值'); 
[U,V]=randPair(B,'vertical',1000); 
vB=ccoef(U,V) 
figure(4),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x+1,y+1)处的像素值') 
[U,V]=randPair(A,'diagonal',1000); 
dA=ccoef(U,V) 
figure(5),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x+1,y+1)处的像素值') 
[U,V]=randPair(B,'diagonal',1000); 
dB=ccoef(U,V) 
figure(6),plot(U,V,'r.');xlabel('点(x,y)处的像素值'); ylabel('点(x+1,y+1)处的像素值') 
P(1,1)=hA;P(1,2)=hB; 
P(2,1)=vA;P(2,2)=vB; 
P(3,1)=dA;P(3,2)=dB;