2013-02-25 63 views
1

我正在研究基于内容的图像检索。从文件夹中检索图像并在matlab图形窗口中显示它

我已经发现这是更相似于该查询图像的图像,并存储结果以矩阵如下

Q =

 100  -1293 
     50  -1237 
     8  -1075 
    102  -1024 
    141  -951 

第一百图像更相似,第50图像是所述第二图像更相似。

所有这些图像都在一个文件夹中。如何在matlab中检索这些图像?

回答

1

我如何

folder = 'c:\images'; % folder were all images are 
img_names; % a cell array where each cell is the name of the image, e.g. img_names{3} is 'photo005.png' 
n = size(q,1); % number of images to be displayed 
w = max(1, floor(sqrt(n))); 
h = ceil(n/w); 
figure('Name','Query results'); 
for ii = 1:n, 
    subplot(w,h,ii); 
    img = imread(fullfile(folder, img_names{ q(ii,1) })); 
    imshow(img); 
    title(sprintf('(%d) img %d score %d', ii, q(ii,1), q(ii,2))); 
end 
+0

得到一个错误“未定义的函数或变量”使用img_names @Shai – Mrk 2013-02-25 11:09:45

+0

@ user2031552 - 你必须自己定义这个变量,所有的文件名加油吧图像按照他们的顺序。 – Shai 2013-02-25 11:32:11

+0

@Mrk'q'是您在问题中定义的查询结果。它由2矩阵'n',第一列为图像索引,第二列为分数。 – Shai 2013-02-25 12:47:38

相关问题