Retrieving images from a folder and displaying it in the figure window of matlab

你。 提交于 2019-12-08 05:22:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!