我有一个二进制图像,比如说 512x512px。我想计算对相关性 g(x)。到目前为止,我正在以原始和无效的方式逐行进行:
function Cr = pairCorr(image)
domains = imread(image); % read image
domains(domains>0) = 1; % make sure its binary by setting 1 to values > 0
size = length(domains(:, 1)); % image size
for i=1:size
line = domains(:, i); % take one line...
for j=1:size % and for each distance...
s = line(1:end-size+j);
Cr(i, j) = mean(s); %...calculate Cr as mean
end
end
Cr = mean(Cr); % average all lines
知道如何更快地做到这一点吗?谢谢!