nlm ¶
This module implements a wrapper for non local means denoisers
Functions:
-
nl_means
–Convenience wrapper for NLMeans implementations.
NLMeans ¶
NLMeans(nl_means_func: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the nl_means function and adds enumerations relevant to its implementation.
It is not meant to be used directly.
Classes:
-
Backend
–Enum representing available backends on which to run the plugin.
-
WeightMode
–Enum of weighting modes for Non-Local Means (NLM) denoiser.
Methods:
-
__call__
–
Source code
30 31 |
|
Backend ¶
Bases: CustomStrEnum
Enum representing available backends on which to run the plugin.
Methods:
-
NLMeans
–Applies the Non-Local Means denoising filter using the plugin associated with the selected backend.
Attributes:
-
ACCELERATOR
–Dedicated OpenCL accelerators.
-
AUTO
–Automatically selects the best available backend.
-
CPU
–An OpenCL device that is the host processor.
-
CUDA
–CUDA (GPU-based) implementation.
-
GPU
–An OpenCL device that is a GPU.
-
ISPC
–ISPC (CPU-based) implementation.
ACCELERATOR class-attribute
instance-attribute
¶
ACCELERATOR = 'accelerator'
Dedicated OpenCL accelerators.
AUTO class-attribute
instance-attribute
¶
AUTO = 'auto'
Automatically selects the best available backend. Priority: "cuda" -> "accelerator" -> "gpu" -> "cpu" -> "ispc".
NLMeans ¶
Applies the Non-Local Means denoising filter using the plugin associated with the selected backend.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
*args
¶Any
, default:()
) –Positional arguments passed to the selected plugin.
-
**kwargs
¶Any
, default:{}
) –Keyword arguments passed to the selected plugin.
Returns:
-
ConstantFormatVideoNode
–Denoised clip.
Raises:
-
CustomRuntimeError
–If the selected backend is not available or unsupported.
Source code
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 |
|
WeightMode ¶
Bases: CustomIntEnum
Enum of weighting modes for Non-Local Means (NLM) denoiser.
Methods:
-
__call__
–:param wref: Amount of original pixel to contribute to the filter output,
Attributes:
-
BISQUARE_HR
–Modified Bisquare weighting function to be even more robust.
-
BISQUARE_LR
–Modified Bisquare weighting function to be less robust.
-
BISQUARE_THR
–Bisquare weighting function use a soft threshold to compare neighbourhoods.
-
WELSCH
–Welsch weighting function has a faster decay, but still assigns positive weights to dissimilar blocks.
-
wref
(float | None
) –
Source code
103 104 105 |
|
BISQUARE_HR class-attribute
instance-attribute
¶
BISQUARE_HR = 3
Modified Bisquare weighting function to be even more robust.
BISQUARE_LR class-attribute
instance-attribute
¶
BISQUARE_LR = 1
Modified Bisquare weighting function to be less robust.
BISQUARE_THR class-attribute
instance-attribute
¶
BISQUARE_THR = 2
Bisquare weighting function use a soft threshold to compare neighbourhoods. The weight is 0 as soon as a given threshold is exceeded.
WELSCH class-attribute
instance-attribute
¶
WELSCH = 0
Welsch weighting function has a faster decay, but still assigns positive weights to dissimilar blocks. Original Non-local means denoising weighting function.
__call__ ¶
__call__(wref: float | None = None) -> WeightMode
Parameters:
-
wref
¶float | None
, default:None
) –Amount of original pixel to contribute to the filter output, relative to the weight of the most similar pixel found.
Returns:
-
WeightMode
–Config with weight mode and ref.
Source code
129 130 131 132 133 134 135 136 137 138 139 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code
33 34 |
|
nl_means ¶
nl_means(
clip: VideoNode,
h: float | Sequence[float] = 1.2,
tr: int | Sequence[int] = 1,
a: int | Sequence[int] = 2,
s: int | Sequence[int] = 4,
backend: Backend = AUTO,
ref: VideoNode | None = None,
wmode: WeightMode = WELSCH,
planes: PlanesT = None,
**kwargs: Any
) -> VideoNode
Convenience wrapper for NLMeans implementations.
Filter description here.
Example:
denoised = nl_means(clip, 0.4, backend=nl_means.Backend.CUDA, ...)
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
h
¶float | Sequence[float]
, default:1.2
) –Controls the strength of the filtering. Larger values will remove more noise.
-
tr
¶int | Sequence[int]
, default:1
) –Temporal Radius. Temporal size =
(2 * d + 1)
. Sets the number of past and future frames to uses for denoising the current frame. d=0 uses 1 frame, while d=1 uses 3 frames and so on. Usually, larger values result in better denoising. Also known as thed
parameter. -
a
¶int | Sequence[int]
, default:2
) –Search Radius. Spatial size =
(2 * a + 1)^2
. Sets the radius of the search window. a=1 uses 9 pixel, while a=2 uses 25 pixels and so on. Usually, larger values result in better denoising. -
s
¶int | Sequence[int]
, default:4
) –Similarity Radius. Similarity neighbourhood size =
(2 * s + 1) ** 2
. Sets the radius of the similarity neighbourhood window. The impact on performance is low, therefore it depends on the nature of the noise. -
backend
¶Backend
, default:AUTO
) –Set the backend to use for processing.
-
ref
¶VideoNode | None
, default:None
) –Reference clip to do weighting calculation. Also known as the
rclip
parameter. -
wmode
¶WeightMode
, default:WELSCH
) –Weighting function to use.
-
planes
¶PlanesT
, default:None
) –Which planes to process.
-
kwargs
¶Any
, default:{}
) –Additional arguments passed to the plugin.
Returns:
-
VideoNode
–Denoised clip.
Source code
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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|