View Full Version : Creating a mask from the differences between two clips
nonoitall
22nd May 2007, 11:58
Topic says it all. I've Googled and searched for hours in vain. Maybe I'm just not using the right terminology, but how can I create a mask based on the absolute differences between two clips?
*.mp4 guy
22nd May 2007, 23:37
c1 = #insert first clip here
c2 = #insert second clip here
yv12lutxy(c1, c2, "x y - abs 255 *", u=3, v=3)
that creates a hard thresholded mask, where the differences between the two clips are white, and everything else is black. You can get different mask characteristics by changing the equation used by yv12lutxy, which is part of the masktools 1 plugin.
nonoitall
23rd May 2007, 02:41
I don't know; I think I'm a little lost, as this is my first time using masks. Here's the function I'm trying to write. (It's meant to look for differences between an original clip and a filtered one, apply a threshold to them to binarize them and then expand the different areas.
function DifferentAreas(clip original, clip filtered) {
#Get the differences between the clips
difference = yv12lutxy(original, filtered, "x y - abs", u=3, v=3)
#Apply a threshold - pixels with a Y value under 40 will be black;
#pixels with a Y value of 40 or higher will be white
difference = difference.YV12LUT("x 40 < 0 255 ?", u=-128, v=-128)
#Expand the differences - this is where the problem starts
difference = difference.Expand()
return difference
}
All goes well until I try to use the Expand function on my binarized mask. Some frames of the difference clip turn green and then back to black. Is this supposed to happen with masks?
*.mp4 guy
23rd May 2007, 03:16
change expand() to expand(u=3, v=3) that should fix the problem.
nonoitall
23rd May 2007, 07:06
That did the trick! Thanks very much!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.