## Cnr2 : Chroma Noise Reducer for AviSynth

(v2.6.1)

### Warning - YV12 inside !!

This filter is designed for Avisynth 2.5
It would work only with Avisynth 2.5 or greater
Needs YUY2 or YV12 input.

### What it does:

this filter is a Chroma Stabilizer for analogic sources
It's a temporal filter and it's very effective against two chroma artifacts :
stationnary rainbows and huge analogic chroma activity.

### Usage :

Add the following lines in your avisynth script :
`
LoadPlugin("Cnr2.dll")
#ex :
Cnr2() # for TV/VHS caps
Cnr2("xxx",4,5,255) # my suggestion to remove rainbows.
`
Syntax :
`
Cnr2([mode]("oxx"),[scdthr](10),[ln](35),[lm](192),[un](47),[um](255),[vn](47),[vm](255),[log](false),[sceneChroma](false))
`
mode

mode of each components, "YUV"
two modes are possible : wide ('o') and narrow ('x')
narrow mode is more sensible to variations, and less effective
Default: "oxx" (String)

scdthr

scene change detection threshold (as percentage
of maximum possible change). If sceneChroma is set
to true, then it is the maximum possible change
including both luma and chroma, if sceneChroma is
set to false then it is the maximum possible change
considering luma only (luma only is more reliable).
lower it to make scene change detection more sensible.
If a scene change is detected, cnr2 will
reset the filtering for the new scene.
Default: 10.0 (float)

ln,lm,un,um,vn,vm : 0 to 255

the n values are the movement sensibility :
higher values will denoise more, but could produce ghosting artifacts
the m values are the maximum effectiveness of the denoiser :
lower them to reduce the denoising effect.
Defaults: ln=35 lm=192 un=47 um=255 vn=47 vm=255

log :

to log the scene change stats (output them using OutputDebugString).
You can use DebugView to see it. It will simply list the detected change,
the maximum allowable change for the current scdthr setting, and the
ratio (at 1.0 or greater a scene change has occurred).
Default: false (bool)

sceneChroma :

sets whether or not both chroma and luma are considered
on scene change detection (true), or only luma (false).
Luma only detection tends to more reliable.
Default: false (bool)

> Cnr2()
> Cnr2("oxx",8,35,192,47,255,47,255,false)
> Cnr2(mode="oxx",scdthr=8,ln=35,lm=192,un=47,um=255,vn=47,vm=255,false)
are three aliases : they would produce the same filtering.

### History :

This Filter is inspired by the Virtual Dub filter Chroma Noise Reduction 1.1 (by Gilles Mouchard)
cnr 1.1 was a good chroma filter but was using YUV conversion to do is job.
I used it for VHS encodes, because it was the better Chroma Noise filter i tested
But when i started to use AviSynth and Huffyuv, RGB convertion was an overhead
So i take a look on the code and wrote my own filter from scratch, but based of the same algo.
the output of cnr2 is 99,9% to 100% the same as cnr (due to YUV colorspace)
and it's 3x-5x faster (Cnr2 can do real-time denoising in 640x480x25fps with a 1,4 Ghz CPU)

version 2.1 (31.7.2002)

little review. corrections.

version 2.2 (01.8.2002)

First frame bug fixed.

version 2.3 (17.11.2002)

YV12 Code and SCD (scene change detection)

version 2.4 (17.11.2002)

small changes/bug fixes

version 2.51 (13.11.2003)

Klaus Post: bug fixes.

version 2.6 (29.06.2004)

tritical: few bug fixes, scene change detection overhaul, code cleanup.

version 2.6.1 (30.06.2004)

tritical: made yuy2 processing fast again.

### Ditribution :

This is a free sofware distribued under the terms of the GNU-GPL
The only restriction is to e-mail me if you want to do something with
the source because i don't want you to lose your time to decode my
cryptic C,C++,Delphi (or any other language) writing.
Thanks :)

### Contact :

Don't even doubt of e-mailing me for any suggestion :-), bug report :-(,
feature request :D, or whatever else :-P.
I hope you'll find this prog useful ! (i do...)

Last update 06.30.04 by tritical