-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
197 lines (117 loc) · 6.79 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
TNLMeans for VapourSynth
originally for AviSynth v2.5.x by tritical, and for VapourSynth by Yusuke Nakamura
HELP FILE
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
INFO:
TNLMeans is an implementation of the NL-means denoising algorithm. Aside from the original
method, TNLMeans also supports extension into 3D and a faster, block based approach.
Syntax =>
tnlm.TNLMeans(int ax, int ay, int az, int sx, int sy, int bx, int by, float a, float h, int ssd)
THEORY OF OPERATION:
The NL-means algorithm works in the following manner. For each pixel in the image define
a search window in which to look for similar pixels. The search window is defined by the
parameters ax and ay, which set the x-axis radius and y-axis radius. For each pixel in the
window determine a weight based on the similarity of that pixel's gray level neighborhood to
the center pixel's gray level neighborhood. The neighborhood is defined by the sx and sy
parameters, which set the x-axis radius and y-axis radius. The similarity between two
neighborhoods is measured using gaussian weighted (as a function of distance, the standard
deviation is set by the "a" parameter) sum of squared differences. The final weight for a pixel
is computed as:
exp(-(total_sse_difference/sum_of_gaussian_weights)/(h*h));
If the parameter 'ssd' is set to false, then sum of absolute differences is used instead of
sum of squared differences. In that case, the final weight for a pixel is computed as:
exp(-(total_sad_difference/sum_of_gaussian_weights)/h);
Once a weight for each pixel in the window is acquired, the final pixel value is simply
the weighted average of all the pixels. In order for the center pixel to not be too heavily
weighted, it is assigned a weight equal to the largest weight given to another pixel in the
search window.
The block based modification changes the base step (or base window) from 1 pixel to blocks
with size bx and by where bx and by set the x-axis radius and y-axis radius. The support and
search windows still work the same way, but now whole blocks are computed/averaged at once
instead of individual pixels. This modification cuts the computation time down by
(bx*2+1)*(by*2+1) times.
The 3D extension allows extending the search window into neighbor frames. The parameter
az sets the temporal (z-axis) radius. With az=1 frames n-1 and n+1 would be included.
More information can be found by following the links to papers about NL-means under
the TNLMeans portion of http://bengal.missouri.edu/~kes25c/.
PARAMETERS:
ax, ay, az -
These set the x-axis, y-axis, and z-axis radii of the search window. These must be
greater than or equal to 0. The full window size will be:
(ax*2+1) x (ay*2+1) x (az*2+1)
Generally, the larger the search window the better the result of the denoising. Of
course, the larger the search window the longer the denoising takes.
Default: ax = 4 (int)
ay = 4 (int)
az = 0 (int)
sx, sy -
These set the x-axis and y-axis radii of the support (similarity neighborhood) window.
These must be greater than or equal to 0. A larger similarity window will retain more
detail/texture but will also cause less noise removal. Typical values for sx/sy are 2
or 3. The full window size will be:
(sx*2+1) x (sy*2+1)
Default: sx = 2 (int)
sy = 2 (int)
bx, by -
These set the x-axis and y-axis radii of the base window. In the original NL-means
algorithm the base was a single pixel (bx=0 and by=0). Using blocks larger than a
single pixel will sacrifice some quality for speed. Note that sx must be greater than
or equal to bx and sy must be greater than or equal to by. It is recommended that
sx/sy be larger than bx/by.
Default: bx = 1 (int)
by = 1 (int)
a -
Sets the standard deviation of the gaussian used for weighting the difference calculation
used for computing neighborhood similarity. Smaller values will result in less noise removal
but will retain more detail/texture.
Default: 1.0 (float)
h -
Controls the strength of the filtering (blurring). Larger values will remove more noise
but will also destroy more detail. 'h' should typically be set equal to the standard deviation
of the noise in the image when using ssd=true and assuming the noise fits the zero mean,
gaussian model.
Default: if ssd = 1 - 1.8 (float)
if ssd = 0 - 0.5 (float)
ssd -
Controls whether sum of squared differences or sum of absolute differences is used when
computing neighborhood similarity. ssd is slightly slower but retains fine detail/texture
better. sad typically works better for cartoons/anime. The 'h' parameter usually needs
to be set about 4 times lower when using sad than when using ssd.
1 - use ssd
0 - use sad
Default: 1
CHANGE LIST:
02/22/2015
- Supported up to 16 bit-depth per plane.
01/15/2015
- Supported VapourSynth native frame-based multi-threading.
01/14/2015
+ Imported for VapourSynth.
+ Supported all planar 8-bit formats.
+ Use VapourSynth native reference counting for frame data instead of copying.
- Removed YUY2 format support.
- Removed multiscale version (parameters ms/rm).
- Renamed 'sse' to 'ssd'.
- Renamed all parameters into lowercases because of the plugin guidelines.
CHANGE LIST (from the AviSynth plugin):
08/28/2007 v1.0.3
- Removed fast exp() approximation that was used for sse=false. Turns out it was quite
inaccurate and had overflow problems resulting in artifacts.
07/30/2006 v1.0.2
- Fixed a problem with small weights causing artifacts
06/19/2006 v1.0.1
- Fixed a bug that caused a crash when ms=true was used with yuy2 input
05/31/2006 v1.0 Final
- Fixed always creating the downsampled clip unless ms=false was explicitly
specified
05/25/2006 v1.0 Beta 2
+ Added multiscale version (parameters ms/rm)
+ Added sse parameter
+ optimized non-block based routines by buffering (100% speed increase)
- removed b parameter
- fixed a bug in the block based routines that caused some blocks
in the search window not to be tested
- changed defaults for ax/ay/sx/sy/h
05/17/2006 v1.0 Beta 1
- Initial Release