DeVCR

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (added category)
(reformat)
Line 1: Line 1:
{{FilterCat4|External_filters|Shared_functions|Restoration_filters|Film_Damage}}
+
{{FilterCat4|External_filters|Scripts|Restoration_filters|Film_Damage}}
== deVCR Filter 1.0 by Ricardo Garcia ==
+
{{Filter3
 +
| Ricardo Garcia  
 +
| v1.0
 +
| [[#Script|Script]]
 +
| VHS Restoration
 +
|
 +
|6=[http://forum.videohelp.com/threads/323093-How-to-use-DeVCR-for-Avisynth VideoHelp]}}
 +
<br>
 +
== Description ==
 +
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.
  
This filter elliminates (to a certain degree) the annoying horizontal lines that keep crawling around your VHS or Beta recorded video.
+
<br>
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)
+
== Requirements ==
{
+
* [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6]
  spacial_data = [[GeneralConvolution]]([[ConvertToRGB]](c),0,"0 -1 0 0 2 0 0 -1 0")
+
* [x64]: [[AviSynth+]]
  bar_data = ConvertToRGB([[BilinearResize]](spacial_data,16,c.height))
+
*Supported color formats: 8-bit RGB and YUV
  st_data = [[Overlay]](bar_data,[[Trim]](bar_data,1,0),mode = "subtract")
+
<br>
  st_data2 = [[GreyScale|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) 
+
}
+
  
 +
== [[Script variables|Syntax and Parameters]] ==
 +
 +
:{{Template:FuncDef|deVCR (clip c, int threshold)}}
 +
<br>
 +
::{{Par2| |clip| }}
 +
:::Input clip; YUV and RGB colorspaces accepted. Clip is converted to RGB.
 +
<br>
 +
::{{Par2||int|}}
 +
:::<code>threshold</code>
 +
<br>
 +
== Script ==
 +
<pre>
 +
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) 
 +
}
 +
</pre>
 +
<br>
 +
== Examples ==
 
Usage example:
 
Usage example:
  
Line 33: Line 59:
  
 
[[Image:devcr.jpg]]
 
[[Image:devcr.jpg]]
 
+
<br>
The filter's not only effective, it's quite fast. Happy transferring!
+
<br>
 +
== External Links ==
 +
*[http://www.digitalfaq.com/forum/video-restore/2607-tracking-lines-video.html DigitalFAQ] - Tracking lines in video; how to fix these VHS tapes?
 +
<br>
 +
<br>
 +
-----------------------------------------------
 +
'''Back to [[External_filters#Film_Damage_correction|External Filters]] &larr;'''
 +
-----------------------------------------------

Revision as of 19:40, 22 June 2020

Abstract
Author Ricardo Garcia
Version v1.0
Download Script
Category VHS Restoration
License
Discussion VideoHelp


Contents

Description

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.


Requirements


Syntax and Parameters

deVCR (clip c, int threshold)


clip   =
Input clip; YUV and RGB colorspaces accepted. Clip is converted to RGB.


int   =
threshold


Script

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)  
}


Examples

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

External Links

  • DigitalFAQ - Tracking lines in video; how to fix these VHS tapes?




Back to External Filters


Personal tools