I’m trying make a video that includes a transition where one image fades into a different image. I would like to do this programmatically (as opposed to using GIMP or video software) so that the result is repeatable and shareable. My starting point is a set of Gadfly plots that I saved out as PNG and then combine into a video with ffmpeg. So the fading could potentially be done either at the plotting stage before saving the images, or after.
Does anyone have any suggestions? Thanks in advance for any help!
You could plot the images with transparency (alpha=0.8) in plots. Reduce the transparency in one image as you increase in the other, plotting both at the same time, during the transition períod.
It would take a fair bit of work for me to convert the plots I have from Gadfly to Plots, but I might switch them over if there is not a clear path forward with just working with Gadfly or the resultant images. But something like you suggest was my initial plan.
There are alpha keywords available. Though I don’t think there is a plot-wide parameter that would fade everything at once and some of plot elements don’t appear to accept alpha values (at least from my reading of the docs).
Is it really better to use transparency here? Isn’t the right approach simply to mix the two images like
img = (1-a) .* img1.+ a .* img2
?
Maybe I have a major misapprehension about alpha and transparency, but I imagine it just mixes in the background rather than representing some inherent property of the foreground.
Ooooh, that works beautifully! I guess I never really thought too much about the difference between transparency versus simple image math. Thanks a lot!