How to read multiple images from multiple folders and display them together?

2 ビュー (過去 30 日間)
PaulLe
PaulLe 2020 年 1 月 8 日
コメント済み: Adam Hooker 2021 年 4 月 23 日
Hi everyone,
I have 3 different folders, each folder includes 100 images (image-1 to image-100).
I want read image-1 (from folder 1), image-1 (from folder 2) and image-1 (from folder 3).
Finally, I want to display 3 images together in figure 1? (image-1 show together image-1, image-2 show together image-2...)
Thank you for your help.
  2 件のコメント
ME
ME 2020 年 1 月 8 日
How are your images stored? Are the Matlab Figure files or are the something else (like png, jpg, etc.)?
PaulLe
PaulLe 2020 年 1 月 8 日
all is .bmp.
Folder1: image-1.bmp, image-2.bmp...
Folder2: image-1.bmp, image-2.bmp...
Folder3: image-1.bmp, image-2.bmp...
Now, i want to read and show in one figure. (3 images image-1.bmp together, 3 images image-2.bmp together...)

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

採用された回答

Bhaskar R
Bhaskar R 2020 年 1 月 8 日
編集済み: Bhaskar R 2020 年 1 月 9 日
selpath = uigetdir; % or selpath = '<your directory full path>';
n_images = 100; % number of images
for ii = 1:n_images
figure(ii),
file = strcat('image-', num2str(ii), '.bmp');
img1 = imread(fullfile(selpath, 'Folder1', file));
img2 = imread(fullfile(selpath, 'Folder2', file));
img3 = imread(fullfile(selpath, 'Folder3', file));
subplot(311), imshow(img1), title(strcat('from folder 1 ', file));
subplot(312), imshow(img2), title(strcat('from folder 2 ', file));
subplot(313), imshow(img3), title(strcat('from folder 3 ', file));
end
  4 件のコメント
Bhaskar R
Bhaskar R 2020 年 1 月 9 日
Corrected sir
Adam Hooker
Adam Hooker 2021 年 4 月 23 日
What if you have too many files to hard code each one?

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by