Displaying images side by side with imshow
8 views (last 30 days)
Show older comments
Damien Sommer
on 11 Apr 2016
Commented: Antonios Patsis
on 2 Jan 2021
Hi everyone ! I'm a student in civil engineering and this semester I have to work on Matlab with images and I'm unfortunately not that comfortable with images. here is my question : I have a camera that take (during one run) 33 fotos. It saved those 33 fotos (called "Image1.jpg", "Image2.jpg" ... "Image33.jpg") In a folder named "run". By using imshow, I manage to plot these 33 photos one next to the other (which is what I want). Here is my code :
clear all;
close all;
for i=1:33, %Insert the number of images that are in the "run" folder
name = sprintf('Image%d.jpg',i);
B{i} = imread(name); % It reads the foto i
I{i} = rot90(B{i},3); % Rotates each Image of the folder by 3*90 degree counterclockwise
end
A = imshow([I{1} I{2} I{3} I{4} I{5} I{6} I{7} I{8} I{9} I{10} I{11} I{12} I{13} I{14} I{15} I{16} I{17} I{18} I{19} I{20} I{21} I{22} I{23} I{24} I{25} I{26} I{27} I{27} I{28} I{29} I{30} I{31} I{32} I{33}]);
My questions are :
1. Is there a way to display those images in a more beautiful way than the one I used : A = imshow ([I{1} I{2}...]), because if suddenly we have 40 fotos, we have to re-write the code manually.
2. To run this code, we have to be in the folder named run, where all the 33 fotos are placed. Let's imagine now that I have j folders named ¨run1¨, ¨run2¨ ...¨runj¨ and each folders contains let's say 33 fotos. The goal is to do the exact same manipulation with each folder, how can I do a loop to do that ?
Thank you very much for your answers, I hope my question is understandable, if not don't hesitate to ask me to clarify it.
Damien
0 Comments
Accepted Answer
Azzi Abdelmalek
on 11 Apr 2016
Edited: Azzi Abdelmalek
on 11 Apr 2016
folder='yourfolder'
A=[];
for i=1:33, %Insert the number of images that are in the "run" folder
name = sprintf('Image%d.jpg',i);
namef=fullfile(folder,name);
B{i} = imread(namef); % It reads the foto i
I{i} = rot90(B{i},3); % Rotates each Image of the folder by 3*90 degree counterclockwise
A=[A I{i}];
end
imshow(A)
3 Comments
Antonios Patsis
on 2 Jan 2021
Hello and Happy New Year,
I would like to ask you, how can I display the same photos, that Damien Sommer said, in a 10x7 matrix and not in a row.
Thank you very much
More Answers (0)
See Also
Categories
Find more on Display Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!