Saving a sequence of images

5 次查看(过去 30 天)
So further to my image processing:
I am reading a video file frame by frame. converting each frame to grayscale, zero'ing all values below 254 in the intensity matix, and then adding these images ontop of on another to build up a kind of time based image showing all the zones a particular event occured.
What I want to do now is save that resulting image after the addtion of each frame so that I end up with a folder full of images, the same number of images that made up the original film. Then I want to assemble them into a movie.
How do I save a sequence of images with a incrementing file name? i.e.
pic1.jpg pic2.jpg pic3.jpg .... pic(x).jpg
?
how do I append that incrementing count number, x, onto the end of the filename?
I tried this
imwrite(Sum,'C:\Documents and Settings\mmam16\My Documents\MATLAB\Pic#%d.jpg',x)
but I dont really know what the #%d does.

采纳的回答

Ashish Uthama
Ashish Uthama 2011-5-5
Alex, you were close.
IMWRITE accepts a string name for the file, it does not know how to insert 'x' into the name. So you should create a string with the file name you want before passing it to IMWRITE:
filename = sprintf('c:\all that\Pic%d.jpg', x);
imwrite(data, filename);
More info here
You can also look at the doc for sprintf for various formatting options (like say zero padding the number).
  4 个评论
Alex Mason
Alex Mason 2011-5-5
oh got it, have to have \\ for back slashes
or else it just thinks you want to save to C: and thats it
kousar majeed
kousar majeed 2019-6-14
i have to save the frame one by one
e.g. 1.1.jpg
1.2.jpg
1.3.jpg
how i can save the frame ... need help

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by