【CBIR】【Color】颜色关联图Color Correlograms

颜色关联图Color Correlograms

【CBIR】【Color】颜色关联图Color Correlograms_第1张图片
function CC_output = Color_Correlograms(img)
%img is simple channel
[rows,cols] = size(img);
H = fspecial('average',3);
imgBlur = imfilter(img,H,'replicate');
M = 64;%量化为N等份
% Ndis = 256/M;%量化距离
% reduceColors = ((imgBlur-Ndis/2)/Ndis)+1;
imgBlur = double(imgBlur);

minpix = min(min(imgBlur));
maxpix = max(max(imgBlur));
reduceColors = round((imgBlur-minpix)/(maxpix-minpix)*(M-1))+1;
d = 8;%距离总数
CC_output = uint16(zeros(M,M,d));
for r = 1:rows
    for c = 1:cols
        ci = reduceColors(r,c);
        for kr = -d:d
            if (r+kr)>0&&(r+kr)<(rows+1)
            for kc = -d:d
                if (c+kc)>0&&(c+kc)<(cols+1)
                    if(kr==0&&kc==0)
                        a = 1;
                    else
                        cj = reduceColors(r+kr,c+kc);
                        index = max(abs(kr),abs(kc));
%                         if index~=0
                            CC_output(ci,cj,index) = CC_output(ci,cj,index)+1;
%                         end
                    end
                end
                
            end
            end
        end
    end
end
CC_output = CC_output/2;
                    


你可能感兴趣的:(【CBIR】【Color】颜色关联图Color Correlograms)