⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 similaritymatrix.m

📁 this m file is describe Similarity matrix for an image
💻 M
字号:
% Works to obtain the Similarity Matrix between two HSV color
% histograms. This is to be used in the Histogram Quadratic 
% Distance equation.

% ------------------------------------------------------------
% Executes on being called, with input matrices I and J.
% ------------------------------------------------------------
function value = similarityMatrix(I, J)

% Obtain the Matrix elements... r - rows, c - columns. The
% general assumption is that these dimentions are the same
% for both matrices.
[r, c] = size(I);

A = [];



for i = 1:r
    for j = 1:r
        % (sj * sin hj - si * sin hi)^2
        M1 = (I(i, 2) * sin(I(i, 1)) - J(j, 2) * sin(J(j, 1)))^2;
        % (sj * cos hj - si * cos hi)^2
        M2 = (I(i, 2) * cos(I(i, 1)) - J(j, 2) * cos(J(j, 1)))^2;
        % (vj - vi)^2
        M3 = (I(i, 3) - J(j, 3))^2;
        
        M0 = sqrt(M1 + M2 + M3);
        
        %A(i, j) = 1 - 1/sqrt(5) * M0;
        A(i, j) = 1 - (M0/sqrt(5));  
    end
end
        
    
%Obtain Similarity Matrix...
value = A;

% ------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -