DeVCR

From Avisynth wiki
Jump to: navigation, search

deVCR Filter 1.0 by Ricardo Garcia

This filter elliminates (to a certain degree) the annoying horizontal lines that keep crawling around your VHS or Beta recorded video. The algorithm: Calculate the difference between each pixel and the pixels above and below (it's horizontal noise we're dealing with), and average large portions (resizing the clip to 16 pixels wide is more than enough) of it to detect the horizontal noise. Then check the difference with the next frame and see if it's effectively temporal noise. After it's detected, just replace each pixel in the noise for the corresponding pixel in the next frame.

function DetectVCRLines(clip c,int threshold)
{
  spacial_data = GeneralConvolution(ConvertToRGB(c),0,"0 -1 0 0 2 0 0 -1 0")
  bar_data = ConvertToRGB(BilinearResize(spacial_data,16,c.height))
  st_data = Overlay(bar_data,Trim(bar_data,1,0),mode = "subtract")
  st_data2 = Greyscale(Levels(st_data,threshold,10.0,threshold+1,0,255,coring = false))
  st_data3 = Greyscale(Levels(st_data2,127,10.0,128,0,255,coring = false))
  st_data4 = Overlay(st_data3,st_data3,y = -1, mode = "add")
  return PointResize(st_data4,c.width,c.height)
}

function deVCR(clip c,int threshold)
{
  mybars = DetectVCRLines(c,threshold)
  return Overlay(c,Trim(c,1,0), mask = mybars,greymask = true)  
}

Usage example:

myclip = AVISource("vcr.avi")
fixedclip = deVCR(myclip,30)
StackHorizontal(myclip,fixedclip,Overlay(myclip,fixedclip,mode = "subtract"))

Here is a result of the filter (original, filtered, diff):

Devcr.jpg

The filter's not only effective, it's quite fast. Happy transferring!

Personal tools