Order Image File Names With Time Stamps

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.

 Accepted Answer

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.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 28 Jul 2014

Answered:

on 28 Jul 2014

Community Treasure Hunt

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

Start Hunting!