Displaying images side by side with imshow

10 ビュー (過去 30 日間)
Damien Sommer
Damien Sommer 2016 年 4 月 11 日
コメント済み: Antonios Patsis 2021 年 1 月 2 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 11 日
編集済み: Azzi Abdelmalek 2016 年 4 月 11 日
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 件のコメント
Damien Sommer
Damien Sommer 2016 年 4 月 14 日
Thanks you ! It worked perfectly ! :)
Antonios Patsis
Antonios Patsis 2021 年 1 月 2 日
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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by