# QUANTIFIED MOTION FILTER (17/08/2003) by HomiE FR (homie.fr@wanadoo.fr) # MOTION ESTIMATION FUNCTION function ME() { # SETTING MOTION LEVEL ACCORDING TO AVERAGE DIFFERENCE [1] global motion_level = (diff < threshold_lm) ? 0 : motion_level global motion_level = (diff >= threshold_lm && diff <= threshold_hm) ? 1 : motion_level global motion_level = (diff > threshold_hm) ? 2 : motion_level } # QUANTIFIED MOTION FILTER FUNCTION function QMF(clip c, float "threshold_lm", float "threshold_hm", bool "debug") { # SETTING MOTION LEVELS THRESHOLDS [2] threshold_lm = default(threshold_lm, 4.0) threshold_hm = default(threshold_hm, 12.0) global threshold_lm = threshold_lm global threshold_hm = threshold_hm # ENABLING/DISABLING DEBUG INFORMATION [3] debug = default(debug, false) # INITIALIZING MOTION LEVEL global motion_level = 0 # SETTING PRESENT CLIP [4] global clip = c # GETTING OUTPUT RESOLUTION [5] width = Width(Low_Motion_Filter(c)) height = Height(Low_Motion_Filter(c)) global c_resized = PointResize(c, width, height) # APPLYING MOTION FILTER ACCORDING TO MOTION LEVEL [6] c = ConditionalFilter(c, Low_Motion_Filter(c), c_resized, "motion_level", "=", "0") # [6a] c = ConditionalFilter(c, Medium_Motion_Filter(c), c, "motion_level", "=", "1") # [6b] c = ConditionalFilter(c, High_Motion_Filter(c), c, "motion_level", "=", "2") # [6c] # PRINTING DEBUG INFORMATION [7] c = (debug == true) ? ScriptClip(c, "Debug()") : c # GETTING MOTION LEVEL THROUGH MOTION ESTIMATION [8] c = FrameEvaluate(c, "ME()") # GETTING DIFFERENCES BETWEEN PAST/PRESENT FRAMES [9] c = FrameEvaluate(c, "global diff = 0.50*YDifferenceFromPrevious(clip) + 0.25*UDifferenceFromPrevious(clip) + 0.25*VDifferenceFromPrevious(clip)") return c } # DEBUG INFORMATION FUNCTION function Debug(clip c) { # PRINTING VERSION INFORMATION [10] c = Subtitle(c, "Quantified Motion Filter", x=20, y=30, font="lucida console", size=18, text_color=$FFFFFF) c = Subtitle(c, "by HomiE FR (homie.fr@wanadoo.fr)", x=20, y=45, font="lucida console", size=14, text_color=$FFFFFF) # PRINTING MOTION ESTIMATION INFORMATION [11] c = Subtitle(c, "motion estimation", x=20, y=85, font="lucida console", size=18, text_color=$FFFFFF) c = Subtitle(c, "diff = "+string(diff), x=20,y=110, font="lucida console", size=16, text_color=$FFCCCC) # PRINTING QUANTIFIED MOTION FILTER INFORMATION [12] c = Subtitle(c, "quantified motion filter", x=20, y=135, font="lucida console", size=18, text_color=$FFFFFF) c = (motion_level == 0) ? Subtitle(c, "scene type = low motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c c = (motion_level == 1) ? Subtitle(c, "scene type = medium motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c c = (motion_level == 2) ? Subtitle(c, "scene type = high motion", x=20, y=160, font="lucida console", size=16, text_color=$66FF66) : c return c }