Averaging a sequence 10 frames at a time
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Averaging a sequence 10 frames at a time
I have a sequence of TGA images recorded from a video game that I wish to convert to a lower frame rate by averaging adjacent images. I'm trying to do this to create temporally super-sampled motion blur.
I only need to average 10 frames into 1 frame but I'm not sure how to go about writing a command line to automate that. Also, I am using Windows.
I only need to average 10 frames into 1 frame but I'm not sure how to go about writing a command line to automate that. Also, I am using Windows.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Averaging a sequence 10 frames at a time
see -evaluate sequence mean (replaces the old -average, which I think can still be used)
http://www.imagemagick.org/script/comma ... e-sequence
convert image1 image2 ... image10 -evaluate sequence mean resultimage
http://www.imagemagick.org/script/comma ... e-sequence
convert image1 image2 ... image10 -evaluate sequence mean resultimage
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Averaging a sequence 10 frames at a time
I probably should have been more clear, I have over 1000 images to work with which I need to process in separate batches.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Averaging a sequence 10 frames at a time
You will have to write a script to loop over all your images and put 10 names in a command to create one 10 image average, then on the next loop, do 10 more.
Are you trying to average all 1000 images or just individual groups of 10?
You might want to see viewtopic.php?f=1&t=19855
Are you trying to average all 1000 images or just individual groups of 10?
You might want to see viewtopic.php?f=1&t=19855
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Averaging a sequence 10 frames at a time
I'm trying to average every 10 frames into a single frame. The idea is to convert 240fps into 24fps to achieve good motion blur.
I see in that thread you have a script but I'm not sure how to apply it to my own situation as I'm not familiar with Linux shell scripting. I have Cygwin so I should be able to execute scripts.
I see in that thread you have a script but I'm not sure how to apply it to my own situation as I'm not familiar with Linux shell scripting. I have Cygwin so I should be able to execute scripts.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Averaging a sequence 10 frames at a time
sumawo13 wrote:I'm trying to average every 10 frames into a single frame. The idea is to convert 240fps into 24fps to achieve good motion blur.
I see in that thread you have a script but I'm not sure how to apply it to my own situation as I'm not familiar with Linux shell scripting. I have Cygwin so I should be able to execute scripts.
That script was to process any number of images into one image. But Anthony thinks that for some large number of images that it will lose accuracy.
For your situation, you should just collect a list of your images (DOS equivalent of ls), then create a loop to take each successive ten images and just use -evaluate sequence to process 10 at a time.
Unfortunately, I am not a Windows person and cannot help in that regard other than point to http://www.imagemagick.org/Usage/windows/
Cygwin should be able to process unix scripts, though one need be careful with some tricky issues, but my script above is not quite what you want.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Averaging a sequence 10 frames at a time
The "xargs" comamnd provides an easy why to do this...sumawo13 wrote:I probably should have been more clear, I have over 1000 images to work with which I need to process in separate batches.
Code: Select all
mkdir average
ls images*.jpg | xargs -n 10 sh -c 'convert "$0" "$@" -average average/"$0" '
The -n argument groups 10 filenames at a time.
The "sh" command is only used to allow the image names to be placed at the start of the "convert" command"
when a shell is invoked in this way $0 is the first argument that follows, and the "convert" command saved the averaged results in the new sub-directory using the filename of the first image "$0" in the average.
Just change the "ls" as appropriate to list all the files in sorted order.
NOTE none of this is actually image processing, but shell scripting. There are lots of good guides, which I have thoroughly read. This is just one 'simple' way of processing 10 filenames at a time.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Averaging a sequence 10 frames at a time
One final point.
Average frames to generate a 'faster' video, will tend to generate very blurry movements.
Skipping frames is the more typical method of doing this.
Average frames to generate a 'faster' video, will tend to generate very blurry movements.
Skipping frames is the more typical method of doing this.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 56
- Joined: 2011-04-23T22:21:52-07:00
- Authentication code: 8675308
Re: Averaging a sequence 10 frames at a time
I had some help from a friend to write a Bash script which I execute through Cygwin.
Here is the resultant file. http://www.mediafire.com/?xcv0k805rnrjuqx
Here is the resultant file. http://www.mediafire.com/?xcv0k805rnrjuqx
- whugemann
- Posts: 289
- Joined: 2011-03-28T07:11:31-07:00
- Authentication code: 8675308
- Location: Münster, Germany 52°N,7.6°E
Re: Averaging a sequence 10 frames at a time
You're obviously working under Windows (when using Cygwin). For the script processing of video, I would then rather recommend AVIsynth + VirtualDub, see http://www.imagemagick.org/Usage/windows/#auxiliary.
Wolfgang Hugemann