matlab - CBIR系统如何计算 "Average Precision and Ranking"

标签 matlab image-processing computer-vision information-retrieval cbir

所以,因为我已经使用 RGB 直方图实现了基本的 cbir 系统。现在,我正在尝试生成平均精度和排名曲线。我需要知道,我的平均精度公式是否正确?以及如何计算平均排名?

Code:
% Dir: parent directory location for images folder c1, c2, c3
% inputImage: \c1\1.ppm
% For example to get P-R curve execute: CBIR('D:\visionImages','\c2\1.ppm');
function [  ] = demoCBIR( Dir,inputImage)
% Dir='D:\visionImages';
% inputImage='\c3\1.ppm';
tic;
S=strcat(Dir,inputImage);
Inp1=imread(S);
num_red_bins = 8;
num_green_bins = 8;
num_blue_bins = 8;
num_bins = num_red_bins*num_green_bins*num_blue_bins;

A = imcolourhist(Inp1, num_red_bins, num_green_bins, num_blue_bins);%input image histogram
srcFiles = dir(strcat(Dir,'\*.jpg'));  
B = zeros(num_bins, 100); % hisogram of other 100 images in category 1
ptr=1;
for i = 1 : length(srcFiles)
    filename = strcat(Dir,'\',srcFiles(i).name);
    I = imread(filename);% filter image
    B(:,ptr) = imcolourhist(I, num_red_bins, num_green_bins, num_blue_bins); 
    ptr=ptr+1;                                                   
end

%normal histogram intersection
a = size(A,2); b = size(B,2); 
K = zeros(a, b);
for i = 1:a
  Va = repmat(A(:,i),1,b);
  K(i,:) = 0.5*sum(Va + B - abs(Va - B));
end


  sims=K;
  for i=1: 100 % number of relevant images for dir 1
     relevant_IDs(i) = i;
  end

 num_relevant_images = numel(relevant_IDs);

 [sorted_sims, locs] = sort(sims, 'descend');
 locations_final = arrayfun(@(x) find(locs == x, 1), relevant_IDs);
 locations_sorted = sort(locations_final);
 precision = (1:num_relevant_images) ./ locations_sorted;
 recall = (1:num_relevant_images) / num_relevant_images;
 % generate Avg precision
 avgprec=sum(precision)/num_relevant_images;% avg precision formula
 plot(avgprec, 'b.-');
 xlabel('Category ID');
 ylabel('Average Precision');
 title('Average Precision Plot');
 axis([0 10 0 1.05]);
end 

最佳答案

是的,没错。您只需将所有精度值相加并取平均值。这就是平均精度的定义。

平均精度只是一个简单的数字(通常以百分比表示),可以为您提供图像检索系统的整体性能。值越高,性能越好。 Precision-Recall 图为您提供有关系统性能的更详细信息,但当您将许多图像检索系统放在一起进行比较时,平均精度很有用。无需绘制许多 PR 图来尝试比较许多检索系统的整体性能,您可以只使用一个表格来比较所有系统以及指定每个系统性能的单个数字 - 即平均精度。

此外,绘制平均精度没有任何意义。当科学论文中通常报告平均精度时,没有绘图……只有一个值!我能看到你绘制它的唯一方法是如果你有一个条形图,其中 y 轴表示平均精度,而 x 轴表示你使用的检索系统正在比较。 bar 越高,准确性越好。然而,一个显示所有不同检索系统的表格,每个检索系统都有其平均精度是非常合适的。这是大多数 CBIR 研究论文中通常采用的做法。


为了解决您的其他问题,您使用平均精度计算平均排名。计算你正在测试的所有检索系统的平均精度,然后根据这个平均精度对它们进行排序。具有较高平均精度的系统将排名较高。

关于matlab - CBIR系统如何计算 "Average Precision and Ranking",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26366545/

相关文章:

machine-learning - 如何取回与从更快的 r-cnn 对象检测过程中获得的强度点相对应的坐标点?

matlab - 为手-前臂分割实现手腕裁剪程序(Matlab)

arrays - 如何知道向量中是否存在连续增加的五个值

MATLAB ismember() 问题

c++ - 对象检测 : Training Requried or No Training Required?

java - java中的骨架化和细化

c++ - 将 Lab 值转换为 opencv 中的 RGB 值

python - 如何在 OpenCV(Python)中将灰度图像转换为 RGB?

matlab - 索引(查询)ndgrid 输出而不实际构建它

performance - 使用稀疏矩阵时的最佳实践