Onion-skin ghost (fake motion blur)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
LDAsh
Posts: 30
Joined: 2015-04-27T23:10:58-07:00
Authentication code: 6789

Onion-skin ghost (fake motion blur)

Post by LDAsh » 2019-05-31T20:11:19-07:00

Wondering if anyone can offer suggestions for a better approach to doing this...
("Version: ImageMagick 6.9.0-1 Q16 x86 2014-12-22")
This basically takes the previous 10 frames and blends them into the current frame, stronger and stronger, to give the illusion of motion blur. It's not 'tweening' because the current frame should be the strongest compared to the previous, and so on. I believe the term is onion-skinning or ghost-framing. Ideally the original frame should be as strong as it actually is, but that is far more complicated than I can figure out when dealing with different scenarios.

Code: Select all

composite inp200.jpg -blend 60x40 inp199.jpg tmp200a.jpg
composite inp198.jpg -blend 60x40 inp197.jpg tmp200b.jpg
composite inp196.jpg -blend 60x40 inp195.jpg tmp200c.jpg
composite inp194.jpg -blend 60x40 inp193.jpg tmp200d.jpg
composite inp192.jpg -blend 60x40 inp191.jpg tmp200e.jpg
composite inp190.jpg -blend 60x40 inp189.jpg tmp200f.jpg
composite tmp200a.jpg -blend 60x40 tmp200b.jpg tmp200z.jpg
composite tmp200c.jpg -blend 60x40 tmp200d.jpg tmp200y.jpg
composite tmp200e.jpg -blend 60x40 tmp200f.jpg tmp200x.jpg
composite tmp200x.jpg -blend 40x60 tmp200y.jpg tmp200z1.jpg
composite tmp200y.jpg -blend 40x60 tmp200z.jpg tmp200z2.jpg
composite tmp200z1.jpg -blend 20x80 tmp200z2.jpg tmp200z9.jpg
composite tmp200z9.jpg -blend 40x60 inp200.jpg out200.jpg

del tmp*.*
Image Image
Image Image

Here's the full script, up to 200 frames:-
http://www.violae.net/temp/onion-skin-ghost_bat.txt
(frame 000 takes its 10 frames from 989-999)

credit to Brad Eustathios for testing animation:-
https://dribbble.com/shots/4442558-Ball-Bounce-Split

User avatar
fmw42
Posts: 25161
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Onion-skin ghost (fake motion blur)

Post by fmw42 » 2019-05-31T21:31:14-07:00

You are using the old limited composite operator. If you use

Code: Select all

convert inp199.jpg inp200.jpg -define compose:args=60,40 -compose blend -composite tmp200a.jpg
you can do all your commands in pairs in once command line using parenthesis processing. That way you do not need to write all the tmp images to disk. Note that in convert you must swap the image order from composite. You can save the first set of tmps to in-memory format such as mpr:tmp200a.jpg which can be reused later in the same command line (or use clones). If you need to save any tmps to disk, you can use the +write tmp in the command line. But I doubt that is needed.

I do not see in your bat file where you make the animation?


See
https://imagemagick.org/Usage/layers/#composition (composite vs convert)
https://imagemagick.org/Usage/compose/#compose
https://imagemagick.org/Usage/compose/#blend_use
https://imagemagick.org/Usage/basics/#parenthesis
https://imagemagick.org/Usage/files/#mpr
https://imagemagick.org/Usage/basics/#clone
https://imagemagick.org/Usage/files/#write

snibgo
Posts: 11831
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Onion-skin ghost (fake motion blur)

Post by snibgo » 2019-06-01T00:15:43-07:00

I call this "temporal supersampling", because we need to generate multiple frames for merging into each output frame. We are subdividing time units.

I show an example at Clut cookbook: Application: Using cluts for animation.
snibgo's IM pages: im.snibgo.com

LDAsh
Posts: 30
Joined: 2015-04-27T23:10:58-07:00
Authentication code: 6789

Re: Onion-skin ghost (fake motion blur)

Post by LDAsh » 2019-06-04T01:53:49-07:00

I had a couple of ideas about how to make this much better, but not sure how realistic they are, or where to even begin...

First would be some way of using some histogram (or similar analysis) verbose output to determine an angle, by comparing 2 or more images and examining where the most pixels have changed and then forming a direction and angle from that information, that could then be used to apply a motion blur for each frame to be blended in. Perhaps not just the angle but the strength of the motion blur to be applied could be ascertained. I've never seen anything claiming to be able to do that, but I imagine it might be possible.

Secondly would be to blend in all of the motion blur by using a "difference arithmetic" (mathematical compose) to create masks, by comparing 2 or more images to determine where the most pixels have changed, cleaning that up and adjusting contrast, then blending in the previous (motion-blurred) frames using those alphas. This way it's not just blending in the entire image and risk losing clarity unnecessarily. Finally, likewise, the difference would be determined between all the ghost frames and the original, the target, to try to preserve that as much as possible, to avoid (for example above) it having that translucent effect when the difference is too great, whether on a dark or bright background. A solution would need to work in both cases.

If any of that even makes any sense, I'm not sure, but that's my brain.

Post Reply