Order Image File Names With Time Stamps

3 次查看(过去 30 天)
Right now I have an image folder with file names as such: 'Name_minute_second_millisecond'
It would look like this: color_01_59_856 meaning it is an image saved at minute 1, 59 seconds, and 856 milliseconds. As I am saving these images into a video file, I want to first order all these image names into an array, so that I can access them one by one and then write them in the correct order.
Is there anyway I can order them relatively easily? I checked out regexp, but I don't think that would work? Please let me know if you have any good suggestions.

采纳的回答

Joseph Cheng
Joseph Cheng 2014-7-28
if you're reading them in with dir('*.imageextension') and with your file name scheme then it should already be in order. if not sortrows() would work for a
Files = dir('*.pic');
for i =1:length(Files)
filenames(i,1) = {Files(i).name};
end
sortedFiles = sortrows(filenames);
this works because you're zero padding the single digit numbers. if not then you can use the _ to parse out the min,sec, and msec and create an array that has the time in one unit and then use sort() to get the order. Use that to re-arrange your image sequence.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by