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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!