rankmd.m
来自「基于小波变换的特征检索算法」· M 代码 · 共 40 行
M
40 行
function rr = rankmd(ms, ics, ns)
% RANKMD Rank relevent images using Mahanalobis distance
%
% Input:
% ms: feature sets, one column per image
% ics: inverse covariance matrices (one page per image)
% ns: (optional), number of subimages per texture class
% (default 16)
%
% Output:
% rr: rank of relevant images, one column for each query
if nargin < 3
ns = 16;
end
nimages = size(ms, 2);
rr = zeros(ns, nimages);
copies = zeros(1, nimages);
ii = 1:nimages;
for q = 1:nimages % each query
% Compute distances of each image in the database to the query
z = ms - ms(:, q+copies);
z = z';
d = sum(z * ics(:,:,q) .* z, 2);
% Sort distances in ascending order
[sd, si] = sort(d);
% Find the rank of the images
r(si) = ii;
% Save the ranks of the relevant images
c = floor((q-1) / ns);
rr(:, q) = r((c*ns+1):((c+1)*ns))';
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?