PDA

View Full Version : Creating a mask only with elements having constant motion on *every* frame


thetoof
18th October 2008, 03:07
On my attempts at creating a mask to do a framerate conversion on bobbed credits to reapply them on an IVTCed background, I ended up with this:
#load the source
source = mpeg2source("source.d2v")

#select the credits
sourceprep = source.trim(credit start, credit end)

#prepare ivtced and bobbed clip
ivtced = sourceprep.tfm().tdecimate()
bobbed = sourceprep.tempgaussmc_beta1()

#apply framerate conversion (basic settings)
bvp = bobbed.MVAnalyse(isb = true, idx=1)
fvp = bobbed.MVAnalyse(isb = false, idx=1)
fpsconv = bobbed.MVFlowFps(bvp, fvp, 24000, 1001, idx=1)

#Create edge mask, expand it to select all the text and expand more to catch lagging credits of the ivtced source (to completely erase the jerky ones when overlaying the good ones)
mask=fpsconv.mt_edge("sobel",7,7,5,5).mt_expand().mt_expand(mode="vertical").mt_expand(mode="vertical").mt_expand(mode="vertical")

#Select only the part of the frame where the credits appear to "minimize the damage" (i.e. to prevent selecting unrelated edges)
cropped=fpsconv.crop(262,0,-38,-0)

#Overlay the corrected credits on the ivtced clip
overlayed=overlay(ivtced,cropped,262,0)

#Merge that overlayed clip on the ivtced clip based on the edge mask
mt_merge(ivtced,overlayed,mask,u=3,v=3)
The problem is that it selects not only the text, but also background edges with plenty of artifacts due to the fps conversion. So, I was wondering if there is any way of changing the mask so that it selects only elements with constant motion in the same direction (straight up or straight down).

If something's unclear, please tell me and I'll try to reformulate it. If it's impossible... nanh, avs is just too powerful :p

Didée
18th October 2008, 03:44
Something simple to try: instead of doing fpsconv->mask, first create bobbed->mask, then do MVFlowFPS(mask). (using same vectors bvp/fvp, but different idx.) That way is more expensive, but should be less prone to misjudge mvflow artifacts for true edges.
Eventually, create a mask in both ways, and combine them with AND or "min" via mt_logic.

Not sure if it'll help much for the problem, but it isn't difficult to try.

thetoof
26th October 2008, 08:08
I had tried applying the framerate conversion on the mask, but it didn't help much. Neither did combining them since some parts of the background are still masked.

The problem is that since I'm overlaying the credits on an ivtced background, the background edges are "lagging" behind because a part of the frame was decimated while the other was crunched temporally, causing spatial discrepancies after the overlay. I can post screenshots if you really need it.
That's the reason why I only want to select the credits. Would it be possible, by adding a mt_lutxy call on the mask, to modify x (mask) by checking y (mask.trim(1,0)) to select only the parts that are still present in y, the only difference being that they moved upward or downward?

The optimal behaviour of the script would be:
1-mask the credits of the interlaced source
2-replace them based on spatio-temporal neighbour pixels of the background (as a logo remover would do)... can logo removal techniques be applied on a "moving logo"??
3-mask the credits of the bobbed clip
4-apply a framerate conversion to overlay them on the ivtced clip

Many thanks for reading and to anyone who will provide (even a tiny bit of) help!

Didée
26th October 2008, 18:07
> I can post screenshots if you really need it.

No, not much need for screenshots, really. I could think of a billion problem points that'll break any possible solution.

Posting a raw sample would be much better. Without being "in touch" with the problem, I've no ideas. Problems are all that I see.