how to select the last image from folder in matlab

조회 수: 2 (최근 30일)
Inggrid Mel
Inggrid Mel 2018년 4월 11일
편집: Stephen23 2018년 4월 13일
I have a lot of pictures and saved in a folder. The images in the folder can continue to grow. I should be able to display the last image that goes into the folder automatically without changing the code.
The code I use:
path = 'E: \ MATLAB Program \ Skrice \ bacteria';
jpeg_files = dir (fullfile (path, '*. jpg'));
for cnt = 43
     I {cnt} = imread (fullfile (path, jpeg_files (cnt) .name));
     figure, imshow (I {cnt});
end
the code is not flexible. Please help. Thank you.

답변 (1개)

the cyclist
the cyclist 2018년 4월 11일
If you call the dir command and assign it to an output ...
fileList = dir
then fileList is a structure, and fileList.date has the file dates.
  댓글 수: 3
the cyclist
the cyclist 2018년 4월 13일
The images will not necessarily be listed in time order. You'll need to take those times as an input, and write some code to find the latest time. If you don't know how to do that, I suggest opening a second question specifically about that.
Stephen23
Stephen23 2018년 4월 13일
편집: Stephen23 2018년 4월 13일
"do you mean the image will be displayed in sequence of time?"
The order of the output of dir is not specified:
  • If you want the files in alphabetical order you will have to sort them yourself: you have the names.
  • If you want the files in chronological order then you will have to sort them yourself: you have the dates.
  • If you want the files listed in size order you will have to sort them yourself: you have the file sizes.
  • etc.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by