Azzera filtri
Azzera filtri

Saving a sequence of images

5 visualizzazioni (ultimi 30 giorni)
Alex Mason
Alex Mason il 5 Mag 2011
Commentato: kousar majeed il 14 Giu 2019
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.

Risposta accettata

Ashish Uthama
Ashish Uthama il 5 Mag 2011
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 Commenti
Alex Mason
Alex Mason il 5 Mag 2011
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 il 14 Giu 2019
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by