Soften

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m
 
(add link to avs+ documentation)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:Func2Def|SpatialSoften(clip ''clip'', int ''radius'', int ''luma_threshold'', int ''chroma_threshold'')|TemporalSoften(clip ''clip'', int ''radius'', int ''luma_threshold'', int ''chroma_threshold'' [, int ''scenechange''] [, int ''mode''])}}
+
<div style="max-width:68em" >
  
The SpatialSoften and TemporalSoften filters remove noise from a video clip by selectively blending pixels. These filters can work miracles, and I highly encourage you to try them. But they can also wipe out fine detail if set too high, so don't go overboard. And they are very slow, especially with a large value of radius, so don't turn them on until you've got everything else ready.  
+
<div {{BlueBox2|40|0|3px solid purple}} >
 +
{{AvsPlusFullname}}<br>
 +
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/soften.html https://avisynthplus.readthedocs.io]
 +
</div>
  
TemporalSoften is similar to SpatialSoften, except that it looks at the same pixel in nearby frames, instead of nearby pixels in the same frame. All frames no more than radius away are examined. This filter doesn't seem to be as effective as SpatialSoften.
 
  
I encourage you to play around with the parameters for these filters to get an idea of what they do--for example, try setting one of the three parameters to a very high value while leaving the others low, and see what happens. Note that setting any of the three parameters to zero will cause the filter to become a very slow no-op.
+
'''SpatialSoften''' and '''TemporalSoften''' remove noise from a video clip by selectively blending pixels.  
  
TemporalSoften smooths luma and chroma separately, but SpatialSoften smooths only if both luma and chroma have passed the threshold.
+
== Syntax and Parameters ==
 +
{{FuncDefH4|SpatialSoften}}
 +
{{FuncDef
 +
|SpatialSoften(clip ''clip'', int ''radius'', int ''luma_threshold'', int ''chroma_threshold'')
 +
}}
  
The SpatialSoften filter work only with YUY2 input. You can use the [[ConvertToYUY2]] filter if your input is not in YUY2 format. Note that large values for radius (>32) will cause AviSynth to crash.
+
Like '''[[Blur]]''', '''SpatialSoften''' blends neighboring pixels in the frame &ndash; but with a wider possible {{FuncArg|radius}}, and only if neighboring pixels are within {{FuncArg|luma_threshold}} and {{FuncArg|chroma_threshold}}, as explained below.  
  
Starting from v2.5 two options are added to TemporalSoften:
+
:{{Par2|clip|clip|}}
 +
:: Source clip. Must be [[YUY2]] color format.
  
*Added ''scenechange=n'' parameter: Using this parameter will avoid blending across scene changes. 'n' defines the maximum average pixel change between frames. Good values for 'n' are between 5 and 30. Requires [[ISSE]].
+
:{{Par2|radius|int|}}
*An optional ''mode=2'' parameter: It has a new and better way of blending frame and provides better quality. It is also much faster.  ''mode=1'' is default operation, and works as always.  
+
::Filter radius &ndash; defines which pixels are processed.  
 +
::Range 0-32; {{FuncArg|radius}}=0 results in no smoothing. Values > 32 may cause AviSynth to crash.
  
[Good initial values: TemporalSoften(4,4,8,15,2)]
+
:{{Par2|luma_threshold, chroma_threshold|int|}}
 +
::When smoothing a given pixel {{Serif|P}}, '''SpatialSoften''' ignores any neighbor pixel {{Serif|P<sub>''n''</sub>}} where:
 +
::*{{Serif|P<sub>''n''</sub>}} luma differs from {{Serif|P}} luma by more than {{FuncArg|luma_threshold}}, OR
 +
::*{{Serif|P<sub>''n''</sub>}} chroma differs from {{Serif|P}} chroma by more than {{FuncArg|chroma_threshold}}.
  
'''Changes:'''
 
  
 +
{{FuncDefH4|TemporalSoften}}
 +
{{FuncDef
 +
|TemporalSoften(clip ''clip'', int ''radius'', int ''luma_threshold'', int ''chroma_threshold'' [, int ''scenechange''] [, int ''mode'' ] )
 +
}}
 +
 +
Blends corresponding pixels in neighboring frames. All frames no more than {{FuncArg|radius}} away are examined. Blending occurs only if corresponding pixels are within {{FuncArg|luma_threshold}} or {{FuncArg|chroma_threshold}}, as explained below.
 +
 +
{{AvsPluscon}} arguments are [[Autoscale_parameter|autoscaling]] &ndash; they are always 0-255 at all bit depths. 
 +
 +
:{{Par2|clip|clip|}}
 +
:: Source clip. Supported color formats: all except [[RGB24]] and [[Avisynthplus_color_formats|RGB48]]
 +
 +
:{{Par2|radius|int|}}
 +
::Filter radius. All frames no more than {{FuncArg|radius}} from the current frame are examined.
 +
::(for {{FuncArg|radius}}=2, FIVE frames are processed: the current frame, two ahead and two behind)
 +
::Range 0-7; {{FuncArg|radius}}=0 results in no smoothing.
 +
 +
:{{Par2|luma_threshold|int|}}
 +
::When smoothing a given luma pixel {{Serif|Y}}, the corresponding pixel in neighboring frame {{Serif|Y<sub>''n''</sub>}}
 +
::is ignored where {{Serif|Y<sub>''n''</sub>}} differs from {{Serif|Y}} by more than {{FuncArg|luma_threshold}}.
 +
 +
:{{Par2|chroma_threshold|int|}}
 +
::When smoothing a given chroma pixel {{Serif|C}}, the corresponding pixel in neighboring frame {{Serif|C<sub>''n''</sub>}}
 +
::is ignored where {{Serif|C<sub>''n''</sub>}} differs from {{Serif|C}} by more than {{FuncArg|chroma_threshold}}.
 +
::*Good starting values are around 1 or 2 times {{FuncArg|luma_threshold}}.
 +
 +
:{{Par2|scenechange|int|0}}
 +
::Defines the maximum average pixel change between frames; set properly, this will avoid blending across scene changes.
 +
::*Good values are between 5 and 30, somewhat higher than {{FuncArg|luma_threshold}}.
 +
::*{{FuncArg|scenechange}} not supported in RGB modes.
 +
 +
:{{Par2|mode|int|1}}
 +
::New scripts should specify {{FuncArg|mode}}=2 to enable [[ISSE]] processing. For backward compatibility, {{FuncArg|mode}}=1 by default.
 +
</div>
 +
 +
 +
== Examples ==
 +
* Good initial values:
 +
<div {{BoxWidthIndent|56|1}} >
 +
TemporalSoften(3, 4, 8, scenechange=15, mode=2)
 +
</div>
 +
 +
 +
== Changes ==
 
{| border="1"
 
{| border="1"
 
|-  
 
|-  
Line 28: Line 82:
  
 
[[Category:Internal filters]]
 
[[Category:Internal filters]]
 +
[[Category:Spatial-Temporal_Denoisers]]

Latest revision as of 19:15, 17 September 2022

AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io


SpatialSoften and TemporalSoften remove noise from a video clip by selectively blending pixels.

Contents

[edit] Syntax and Parameters

SpatialSoften

SpatialSoften(clip clip, int radius, int luma_threshold, int chroma_threshold)

Like Blur, SpatialSoften blends neighboring pixels in the frame – but with a wider possible radius, and only if neighboring pixels are within luma_threshold and chroma_threshold, as explained below.

clip  clip =
Source clip. Must be YUY2 color format.
int  radius =
Filter radius – defines which pixels are processed.
Range 0-32; radius=0 results in no smoothing. Values > 32 may cause AviSynth to crash.
int  luma_threshold, chroma_threshold =
When smoothing a given pixel P, SpatialSoften ignores any neighbor pixel Pn where:
  • Pn luma differs from P luma by more than luma_threshold, OR
  • Pn chroma differs from P chroma by more than chroma_threshold.


TemporalSoften

TemporalSoften(clip clip, int radius, int luma_threshold, int chroma_threshold [, int scenechange] [, int mode ] )

Blends corresponding pixels in neighboring frames. All frames no more than radius away are examined. Blending occurs only if corresponding pixels are within luma_threshold or chroma_threshold, as explained below.

AVS+ arguments are autoscaling – they are always 0-255 at all bit depths.

clip  clip =
Source clip. Supported color formats: all except RGB24 and RGB48
int  radius =
Filter radius. All frames no more than radius from the current frame are examined.
(for radius=2, FIVE frames are processed: the current frame, two ahead and two behind)
Range 0-7; radius=0 results in no smoothing.
int  luma_threshold =
When smoothing a given luma pixel Y, the corresponding pixel in neighboring frame Yn
is ignored where Yn differs from Y by more than luma_threshold.
int  chroma_threshold =
When smoothing a given chroma pixel C, the corresponding pixel in neighboring frame Cn
is ignored where Cn differs from C by more than chroma_threshold.
  • Good starting values are around 1 or 2 times luma_threshold.
int  scenechange = 0
Defines the maximum average pixel change between frames; set properly, this will avoid blending across scene changes.
  • Good values are between 5 and 30, somewhat higher than luma_threshold.
  • scenechange not supported in RGB modes.
int  mode = 1
New scripts should specify mode=2 to enable ISSE processing. For backward compatibility, mode=1 by default.


[edit] Examples

  • Good initial values:
TemporalSoften(3, 4, 8, scenechange=15, mode=2)


[edit] Changes

v2.56 TemporalSoften working also with RGB32 input (as well as YV12, YUY2)
Personal tools