cbir_cosinedist.m
来自「matlab编程」· M 代码 · 共 17 行
M
17 行
function dist = CBIR_cosinedist(x1, x2)
% EE6850 HW3, Content-Based Image Retrieval
% CBIR_cosinedist() --- Cosine distance of a given feature vector pair
% input:
% feature vector x1 and x2 (1xN)
% output:
% their cosine distance (0~1)
% 10-24-2001, xlx@ee.columbia.edu
if sum(size(x1)==size(x2))~=2
error('To calculate cosine distance, matrix dimension must agree');
end
costheta = sum(x1(:).*x2(:))/...
sqrt( x1(:)'*x1(:) * x2(:)'*x2(:));
dist = acos(costheta)*2/pi;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?