Color correlogram combines the color and space information in the image to construct a histogram using the quantitative distance between colors (different colors or the same color. The traditional color histogram only considers the color information. Example:
The left-side image and the right-side image have the same color histogram information. If the spatial location relationship between colors is not considered, it is difficult to distinguish the two images.
Modeling
Assume that the mark of the image is I (x, y), and X and Y are spatial coordinates. The colors include C1, C2, c3... CN. set the distance between the two colors to D. then we will generate a histogram like this: the number of bin is the square of N (the number of color combinations). For each bin, the bin size is
Bin (CI, CJ) = Σ X, Y {| I (x, y, CI)-I (X, Y, CJ) ||= d }. Where, | * | indicates the spatial distance between two pixels of CJ With the pixel value CI, and then counts the number of such pixels. Therefore, if we set the distance D1, D2, D3. .. DM (d in total). The bin dimension is (N * n * D ).
Furthermore, we only consider the spatial relationship between the same colors. The bin dimension of the color auto-correlogram is (N * D ).
Experiment
Color histogram rank: 310 Autocorrelogram
Rank: 5
This is the application of color-related graphs in content-based image retrieval, which is higher than the original rank result.
Code
% % %
FunctionOutput = colorcorrelogram (RGB, d)
R = RGB (:,:, 1 );
G = RGB (:,:, 2 );
B = RGB (:,:, 3 );
R_bits = 2; % bit quantization
G_bits = 2;
B _bits = 2;
Size_color = 2 ^ r_bits * 2 ^ g_bits * 2 ^ B _bits; % Number of normalized colors
R1 = bitshift (R,-(8-r_bits ));
G1 = bitshift (G,-(8-g_bits ));
B1 = bitshift (B,-(8-b_bits ));
% Colors: 4x4x4
I = R1 + G1 * 2 ^ r_bits + B1 * 2 ^ r_bits * 2 ^ B _bits; % New Image
Temp = zeros (size_color, 1 );
OS = offset (d );
S = size (OS );
For I = 1: S (1)
Offset = OS (I ,:);
GLM = glcmatrix (I, offset, size_color );
Temp = temp + GLM;
End
Hc = zeros (size_color, 1 );
For J = 0: size_color-1
HC (J + 1) = numel (I = J); % index indicates the Count of J.
End
Output = temp./(HC + EPS );
Output = output/(8 * D );
End
Function OS = offset (d)
[R, C] = meshgrid (-D: D,-D: d );
R = R (:);
C = C (:);
OS = [R C];
Bad = max (ABS (R), ABS (c ))~ = D;
OS (bad, :) = [];
End
Function out = glcmatrix (Si, offset, NL)
S = size (SI); % image size
[R, C] = meshgrid (1: S (1), 1: S (2); % gridded, obviously
R = R (:); % Vectoring
C = C (:); % Vectoring
R2 = R + offset (1); % offset
C2 = C + offset (2); % offset
Bad = c2 <1 | c2> S (2) | R2 <1 | r2> S (1); % filter the points where the index is not in the image
Index = [r c R2 C2]; % matrix of original distance and relative distance
Index (bad, :) = []; % remove bad points
V1 = Si (sub2ind (S, index (:, 1), index (:, 2); % from index to data
V2 = Si (sub2ind (S, index (:, 3), index (:, 4 )));
V1 = V1 (:);
V2 = v2 (:);
IND= [V1 V2];
Bad = V1 ~ = V2; % the color auto-correlation diagram is calculated here.
Ind (bad, :) = [];
If isempty (IND)
Oneglcm2 = zeros (NL );
Else
Oneglcm2 = accumarray (IND + 1, 1, [NL, NL]);
End
Out = [];
For I = 1: NL
Out = [out oneglcm2 (I, I)];
End
Out = out (:);
End
% % %
Reference
Http://www.cs.cornell.edu/rdz/Papers/ecdl2/spatial.htm