CelStabilize

From Avisynth wiki
Jump to: navigation, search
Abstract
Author mg262
Version 23rd September 2005
Download
Category Stabilizers
License
Discussion Doom9 Thread

Contents

Description

CelStabilize - a stabilization script, designed for animations. The movement typically comes from the process that scans the animation to video; resulting in jerkiness. Just to emphasize, this filter is primarily meant for animation, especially old animation, although it should work on live material if the background is reasonably still.


These are the distinctive features of this filter[1]:

  1. It takes masks specifying regions to ignore.
  2. It works on a scene by scene basis and tries to stabilize still scenes completely rather than applying a filter to reduce the motion (this isn't "better" than the alternatives -- they're suitable for different tasks).
  3. The sensitivity to different luma-differences is specifiable.

3 is a bit cryptic, so here is some explanation. When you try to stabilize the motion, you are roughly doing this: take frame n+1, put it on top of frame n, and slide it around until you find a good match. (Think of n+1 as semitransparent.) The standard ways to judge how good a match are

A) add up the differences of the luma values (i.e. of each pair of pixels that lie on top of each other.)
B) add up the squares of the differences of the luma values. So you slide around n+1 to try and make this number as small as possible.

Both methods say that a white object "matches" a black background much worse than a grey object does -- whereas in fact, they are equally bad. Above a certain level, depending on noise but always relatively small, bigger differences don't mean anything... so the filter lets you specify the "penalty" for each luma difference. (+this has subtler uses which I won't go into now.)

Requirements

  • AviSynth 2.5.8 or greater
  • Supported color formats: YV12

Required Plugins


Script

CelStabilise.avs

function Stabilise(clip o, clip metric)
{
Selectall(o)
SelectFirstOfRun()
scene = Breakon(last)
FindIntegerPan (o, metric)
UnmaskedRefinePan(o, metric, last)
motion = last.ScaleMotion(-1.0)
totalmotion = AccumulateMotion(scene, motion)
# Stabilise
ApplyUnmaskedPowerTranslate(o, totalmotion, o)#.Expand(900, 640))
return Paper()
}


Examples

LoadPlugin("CelBackground_23Sep05.dll")
Import("CelStabilise.avs")
AviSource("blah.avi") Stabilise(capabsolutemetric(15))
#Crop(4, 4, -4, -4, align=true) #or as appropriate to remove borders created by stabilization

Identical to the sample above but written differently:

AviSource("blah.avi")
metric = CapAbsoluteMetric(last, 15) 
Stabilise(last, metric)


External Links




Back to External Filters

Personal tools