# 显著性检测AC方法

AC算法通过计算一个感知单元在不同邻域上的局部对比度来实现多尺度显著性计算。内部区域R1，外部区域R2，计算R1和R2的局部对比度时，通过改变R2的大小实现多尺度显著性计算。

AC方法采用Lab颜色特征，采用欧氏距离计算特征距离。R1默认为一个像素，R2边长为[L/8，L/2]之间的正方形区域，L为长宽中较小者。多个尺度的特征显著图通过直接相加得到完整的显著图。

【MATLAB实现】

dim = size(img);
width = dim(2);height = dim(1);
md = min(width, height);

lab=RGB2Lab(img);
l = double(lab(:,:,1));
a = double(lab(:,:,2));
b = double(lab(:,:,3));
%If you have your own RGB2Lab function...
%[l a b] = RGB2Lab(gfrgb(:,:,1),gfrgb(:,:,2), gfrgb(:,:,3));

sm = zeros(height, width);
off1 = int32(md/2); off2 = int32(md/4); off3 = int32(md/8);%3个尺度
for j = 1:height
y11 = max(1,j-off1); y12 = min(j+off1,height);
y21 = max(1,j-off2); y22 = min(j+off2,height);
y31 = max(1,j-off3); y32 = min(j+off3,height);
for k = 1:width
x11 = max(1,k-off1); x12 = min(k+off1,width);
x21 = max(1,k-off2); x22 = min(k+off2,width);
x31 = max(1,k-off3); x32 = min(k+off3,width);
lm1 = mean2(l(y11:y12,x11:x12));am1 = mean2(a(y11:y12,x11:x12));bm1 = mean2(b(y11:y12,x11:x12));
lm2 = mean2(l(y21:y22,x21:x22));am2 = mean2(a(y21:y22,x21:x22));bm2 = mean2(b(y21:y22,x21:x22));
lm3 = mean2(l(y31:y32,x31:x32));am3 = mean2(a(y31:y32,x31:x32));bm3 = mean2(b(y31:y32,x31:x32));

cv1 = (l(j,k)-lm1).^2 + (a(j,k)-am1).^2 + (b(j,k)-bm1).^2;
cv2 = (l(j,k)-lm2).^2 + (a(j,k)-am2).^2 + (b(j,k)-bm2).^2;
cv3 = (l(j,k)-lm3).^2 + (a(j,k)-am3).^2 + (b(j,k)-bm3).^2;
sm(j,k) = cv1 + cv2 + cv3;
end
end
sm=sm./max(sm(:));%sm矩阵中的每一个值都除以sm矩阵中的最大值，归一化
imshow(sm);