为了找到两个相邻像素(水平,垂直和对角线)之间的相关性,我从原始图像和加密图像中随机选择了相邻像素对 . 我使用了内置的MATLAB函数 corrcoef 但是我没有得到结果 . 在计算相关系数之前,我是否需要找到像素的均值,方差和协方差?如果我在哪里使用它在函数中?这个函数似乎没有使用任何值 . 我使用以下代码计算水平相邻的像素

m1 = A(:,1:end-1,1);  %# All rows and columns 1 through 255 
n1 = A(:,2:end,1);    %# All rows and columns 2 through 256 
                      % A is the original image
randIndex1 = randperm(numel(m1));  %# A random permutation of the integers
                                   %#   from 1 to numel(m1)
randIndex1 = randIndex1(1:3000);   %# Pick the first 3000 indices
m1Rand = m1(randIndex1);            %# 3000 random values from m1
n1Rand = n1(randIndex1);            %# The corresponding 3000 values from n1 

r_mn1 = corrcoef(m1Rand(:),n1Rand(:)); disp('r_mn1=');disp(r_mn1);

我确实有计算均值,方差,协方差和相关系数的公式 . 我想知道在这种情况下是否可以使用内置函数,还是应该使用公式计算?请帮忙 . 提前致谢 .