Log in

View Full Version : Quasi Alpha Channel for Image Sequence?


Pookie
22nd August 2006, 03:11
Trying to figure out a workaround on this one, but I'm feeling even dumber than usual.

PNG Sequence w Alpha Channel --> Add Motion Blur --> Output PNG Sequence w Alpha Channel

CoronaSequence("c:\input\*.png", sort=1)

converttoyv12() # kill the alpha channel

source=last
backward_vectors = source.MVAnalyse(isb = true, truemotion=true)
forward_vectors = source.MVAnalyse(isb = false, truemotion=true)
z=source.MVFlowBlur(backward_vectors, forward_vectors, blur=30)
return z.converttorgb32().ImageWriter("C:\output\",start=0, type = "png")


Beautiful looking motion blur, but alpha channel long gone...

Notes:

- I believe CoronaSequence output is RGB32
- MVtools requires YV12 or YUY2
- Perhaps motion blur that works in RGB is available?
- Perhaps Masktools could create a Pseudo Alpha Mask which can be layered back on the image sequence ?

Mug Funky
22nd August 2006, 04:18
i think there was a filter that could turn an R, G or B channel into a Y channel with zeroed chroma. possibly even one for the alpha channel.

if that's the case, run your MVanalyse steps on a converttoyv12'd version of the source, then apply the mvblur steps 4 times (using the vectors you got earlier) and merge back to RGB.

this method will be the same as working in RGB but slightly slower :). there'll be no blurring from converting to yv12 and back.

[edit]

ah! it's all in the manuals on avisynth.org :)

CoronaSequence("c:\input\*.png", sort=1)

r=last.showred("yv12")
g=last.showgreen("yv12")
b=last.showblue("yv12")
a=last.showalpha("yv12")
sourceyv12=last.converttoyv12() # kill the alpha channel

backward_vectors = sourceyv12.MVAnalyse(isb = true, truemotion=true)
forward_vectors = sourceyv12.MVAnalyse(isb = false, truemotion=true)
rblur=r.MVFlowBlur(backward_vectors, forward_vectors, blur=30)
gblur=g.MVFlowBlur(backward_vectors, forward_vectors, blur=30)
bblur=b.MVFlowBlur(backward_vectors, forward_vectors, blur=30)
ablur=a.MVFlowBlur(backward_vectors, forward_vectors, blur=30)
return mergeargb(ablur,rblur,gblur,bblur).ImageWriter("C:\output\",start=0, type = "png")

let me know if it works... i haven't tested it. if it says "no such function" or whatever, try a later version of avisynth (i'm on 2.56, sep 4 2005 build... yikes that's old)

Pookie
22nd August 2006, 05:06
Mug Funky- Initial Results look promising :D The output certainly has alpha channel now-I need to check that the motion blur is stable (if that makes any sense).

Update: It works very nicely indeed. As a side note, the motion blur is more accurate with
search=3 parameter in MVanalyse. Also, the images benefit by a limitedsharpen call on each channel.

Thanks, dude. You da man. :)