sum_distance.m

来自「用Cross validation的方法建立人工神经网络的模型!」· M 代码 · 共 28 行

M
28
字号
%  function distance = Sum_distance(x_compressed, y_compressed, cdbk_distance): image
%  similarity calculation based on sumation of Euclidean distance over all 
%  pairs of codewords
% 
% Input:    x_compressed -- 1*N, a row stores all indices of keyblocks to
%                           represent the current image x
%           y_compressed -- 
%          cdbk_distance -- nwds*nwds matrix, cdbk_similarity(i,j)
%                           represents the distance between ith and jth
%                           codeword in codebook
% Output: 
%               distance -- float number, the similarity between image x
%                           and y
%

function distance = Sum_distance(x_compressed, y_compressed, cdbk_distance)

nwds = size(cdbk_distance, 1);
n_point = size(x_compressed, 2);

distance = 0;

for i = 1: n_point
    distance = distance + cdbk_distance(x_compressed(i), y_compressed(i));
end

distance = sqrt(distance);

⌨️ 快捷键说明

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