📄 rankmd.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -