Displaying images side by side with imshow
조회 수: 18 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
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 Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!