Log in

View Full Version : Apply filter to rectangular parts of frame


absence
7th March 2010, 18:09
Is there an easy way to apply a filter on only some rectangular parts of a frame? I imagine I have to make a filtered clip in addition to the original clip, and then use a filter to mix them based on the coordinates of the rectangle(s), but I haven't found out how.

poisondeathray
7th March 2010, 18:23
one way to approach this might be to use overlay() for one filtered clip onto the other, and x,y coordinates

http://avisynth.org/mediawiki/Overlay

Didée
7th March 2010, 18:51
Assuming your clips are in YV12 colorspace, of same dimensions, and you have MaskTools v2, then a very fast way is to use mt_lutxy in conjunction with its "offx","offy","w","h" parameters.

Say, the box to overlay has its left-top corner at (160,80), is 320px in width, 240px in height:

a = AviSource("clip1.avi")
b = AviSource("clip1_filtered.avi")

mt_lutxy(a,b,"y", offx=160,offy=80, w=320,h=240, Y=3,U=3,V=3)

absence
7th March 2010, 19:21
Assuming your clips are in YV12 colorspace, of same dimensions, and you have MaskTools v2, then a very fast way is to use mt_lutxy in conjunction with its "offx","offy","w","h" parameters.

That works very well, and if I need more than one rectangle I can nest several mt_lutxy calls. Thanks! :)

MadRat
8th March 2010, 03:49
Looks like this question was answered but just in case someone comes across this thread and wants more information...

There are two threads were I asked a similar question. There's one one how to use overlay http://forum.doom9.org/showthread.php?t=150078 and one on how to use GraMaMa to make a mask on-the-fly http://forum.doom9.org/showthread.php?t=134499