Subplotting many images in one figure
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Edu PL
le 12 Fév 2014
Commenté : Khan Bahadar Khan
le 11 Mai 2019
Hi there,
I am pretty ignorant about matlab but starting to learn.
Here I am trying to subplot a group of images located in a folder. The names of the pictures are like "Point01Pic1_140127","Point01Pic1_140128".... "Point02Pic1_140127", "Point02Pic2_140128"...
being the date the final part of the name. the idea is to plot all of them in the same figure with the purpose of comparison.
I am trying something like this:
clear all
clc
a = uigetdir;
A = dir( fullfile(a, '*.jpg') );
fileNames = { A.name };
for iFile = 1 : numel( A )
newName = fullfile(a, sprintf( '%03d.jpg', iFile ) );
movefile( fullfile(a, fileNames{ iFile }), newName );
end
subplottight(2,4,1), imshow('008.jpg', 'border', 'tight');
subplottight(2,4,2), imshow('006.jpg', 'border', 'tight');
subplottight(2,4,3), imshow('004.jpg', 'border', 'tight');
subplottight(2,4,4), imshow('002.jpg', 'border', 'tight');
subplottight(2,4,5), imshow('007.jpg', 'border', 'tight');
subplottight(2,4,6), imshow('005.jpg', 'border', 'tight')
subplottight(2,4,7), imshow('003.jpg', 'border', 'tight');
subplottight(2,4,8), imshow('001.jpg', 'border', 'tight');
Doing this way I am renaming the files like "001", "002" (I dont know how to handle the orig. names) etc getting a 2x4 subplot with the right arragement but I would like to use the original names (ie "Point02Pic2_140128" for example)and have all the pictures of "Point 1" in one row in cronological order, all the pictures of "Point2" in the next row etc.
I hope I explained myseld clear enough.
Thanks for the patience and any help will be appreciated.
0 commentaires
Réponse acceptée
Mischa Kim
le 12 Fév 2014
Modifié(e) : Mischa Kim
le 12 Fév 2014
Edu, this should do:
for ii = 1:8
file_name = strcat('Point0',num2str(ceil(ii/4)),'Pic',num2str(ii-4*(ii>4)),'_140128.jpg')
subplottight(2,4,ii), imshow(file_name, 'border', 'tight');
end
assuming your image files end with _140128 (not quite sure I understand the file name sequence). If they do not, I am sure with the above code snippet you can figure out how to adjust the code.
5 commentaires
Plus de réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

