一千零一夜的博客

以此博客,见证我的终生学习

Matlab 显著性检测模型性能度量CC

% created: Zoya Bylinskii, Aug 2014

% This finds the linear correlation coefficient between two different 
% saliency maps (also called Pearson's linear coefficient).
% score=1 or -1 means the maps are correlated
% score=0 means the maps are completely uncorrelated

function score = CC(saliencyMap1, saliencyMap2)
% saliencyMap1 and saliencyMap2 are 2 real-valued matrices

map1 = im2double(imresize(saliencyMap1, size(saliencyMap2)));
map2 = im2double(saliencyMap2);
% map1=saliencyMap1;
% map2=saliencyMap2;

% normalize both maps
map1 = (map1 - mean(map1(:))) / std(map1(:)); 
map2 = (map2 - mean(map2(:))) / std(map2(:)); 

score = corr2(map2, map1);
function r = corr2(varargin)

[a,b] = ParseInputs(varargin{:});

a = a - mean2(a);
b = b - mean2(b);
r = sum(sum(a.*b))/sqrt(sum(sum(a.*a))*sum(sum(b.*b)));

%--------------------------------------------------------
function [A,B] = ParseInputs(varargin)

narginchk(2,2);

A = varargin{1};
B = varargin{2};

validateattributes(A, {'logical' 'numeric'}, {'real','2d'}, mfilename, 'A', 1);
validateattributes(B, {'logical' 'numeric'}, {'real','2d'}, mfilename, 'B', 2);

if any(size(A)~=size(B))
    error(message('images:corr2:notSameSize'))
end

if (~isa(A,'double'))
    A = double(A);
end

if (~isa(B,'double'))
    B = double(B);
end




关键代码:

r = sum(sum(a.*b))/sqrt(sum(sum(a.*a))*sum(sum(b.*b)));

可以用公式表示,图a,b的相关性大小,越大越相关:

 

阅读更多
上一篇Matlab显著性检测模型性能度量之NSS
下一篇【吴恩达 机器学习】线性回归算法Matlab实现
想对作者说点什么? 我来说一句

SR显著性MATLAB代码

2015年12月03日 567B 下载

没有更多推荐了,返回首页

关闭
关闭