cbir_histintersection.m

来自「matlab编程」· M 代码 · 共 25 行

M
25
字号
function dist = CBIR_histintersection(x1, x2)
% EE6850 HW3, Content-Based Image Retrieval
% CBIR_histintersection() --- intersection of two histograms
% input:
%   feature vector x1 and x2 (1xN)
% output:
%    1 - their intersection 
% [ref] section 4.3.1.1, John R. Smith, 
% "Integrated Spatial and Feature Image Systems: Retrieval, Analysis and Compression", 
% Ph.D. thesis, Columbia Univ. 1997
%
% 10-25-2001, xlx@ee.columbia.edu

if sum(x1(:)<0) | sum(x2(:)<0)
    error('histogram must be non-negative');
end
if sum(size(x1)==size(x2))~=2
    error('To calculate intersection, vector dimension must agree');
end

dist = sum(min([x1(:)'; x2(:)']));
denom = min([sum(x1(:)),sum(x2(:))])+1e-8;
dist = dist/denom;
    
dist = 1-dist;

⌨️ 快捷键说明

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