问题
I am working on content based image retrieval.
I have found the images which are more similar to the query image and stored the result in a matrix as follows
q =
100 -1293
50 -1237
8 -1075
102 -1024
141 -951
100th image is more similar, 50th image is the second image that is more similar.
All these images are in a folder. How to retrieve these images inside matlab ?
回答1:
How about
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
来源:https://stackoverflow.com/questions/15064387/retrieving-images-from-a-folder-and-displaying-it-in-the-figure-window-of-matlab