How to show all jpg images saved in MATLAB folder?

5 ビュー (過去 30 日間)
Explorer
Explorer 2016 年 2 月 1 日
編集済み: DGM 2023 年 2 月 24 日
storedStructure = dir('*.jpg')
How should I proceed?
  2 件のコメント
Stephen23
Stephen23 2016 年 2 月 1 日
編集済み: Stephen23 2016 年 2 月 1 日
What do you mean "show all jpg images" ? If you have a thousand images, displaying them all at once could be a bit bewildering.
Explorer
Explorer 2016 年 2 月 1 日
Yes, it may be. But still I want to know how can I do this?

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

採用された回答

Stephen23
Stephen23 2016 年 2 月 1 日
編集済み: Stephen23 2016 年 2 月 1 日
This displays all of the jpg images in the current directory:
S = dir('*.jpg');
for k = 1:numel(S)
figure();
image(imread(S(k).name))
axis('image');
end
Note: this code will not work with indexed image formats.

その他の回答 (4 件)

Bjorn Gustavsson
Bjorn Gustavsson 2016 年 2 月 1 日
Perhaps one of the submissions creating thumbnails (into tables guis or the like) found on the file exchange does what you want: Thumbnaily submissions

DGM
DGM 2023 年 2 月 14 日
編集済み: DGM 2023 年 2 月 24 日
(Almost) straight from the docs for montage:
% Create a montage from a series of JPG images in a directory
targetpath = fullfile(matlabroot,'toolbox','images','imdata','*.jpg');
imds = imageDatastore(targetpath);
montage(imds);
Alternatively, without using imageDatastore():
% Create a montage from a series of JPG images in a directory
targetpath = fullfile(matlabroot,'toolbox','images','imdata','*.jpg');
S = dir(targetpath);
allpaths = fullfile({S.folder},{S.name});
montage(allpaths);
In either case, if you want to actually save the output to a new image file, don't use montage(). Use imtile() instead and save the result using imwrite(). Most of the syntax overlaps between the two, so it should be fairly straightforward.

Walter Roberson
Walter Roberson 2016 年 2 月 1 日
ls *.jpg
if you just want to list them to the screen.
  1 件のコメント
Explorer
Explorer 2016 年 2 月 1 日
No, I do not want their names. I want to show images.

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


Image Analyst
Image Analyst 2016 年 2 月 1 日
This is answered in the second chunk of code in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by