spat_funcs ¶
Functions:
-
adg_mask
–Generates an adaptive grain mask based on each frame's average luma and pixel value.
-
flat_mask
– -
retinex
–Multi-Scale Retinex (MSR) implementation for dynamic range and contrast enhancement.
-
texture_mask
–
adg_mask ¶
adg_mask(
clip: VideoNode,
luma_scaling: float | Sequence[float] = 8.0,
relative: bool = False,
func: FuncExceptT | None = None,
) -> ConstantFormatVideoNode | list[ConstantFormatVideoNode]
Generates an adaptive grain mask based on each frame's average luma and pixel value.
This function is primarily used to create masks for adaptive grain applications but can be used in other scenarios requiring luminance-aware masking.
Parameters:
-
clip
¶VideoNode
) –The clip to process.
-
luma_scaling
¶float | Sequence[float]
, default:8.0
) –Controls the strength of the adaptive mask. Can be a single float or a sequence of floats. Default is 8.0. Negative values invert the mask behavior.
-
relative
¶bool
, default:False
) –Enables relative computation based on pixel-to-average luminance ratios. Requires the akarin plugin. If True without akarin, an error is raised.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
ConstantFormatVideoNode | list[ConstantFormatVideoNode]
–A single mask or a list of masks (if
luma_scaling
is a sequence), corresponding to the input clip.
Raises:
-
CustomRuntimeError
–If the akarin plugin is not available and either
relative
is True or the clip is in fp16 format.
Source code
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 |
|
flat_mask ¶
flat_mask(
src: VideoNode, radius: int = 5, thr: float = 0.011, gauss: bool = False
) -> ConstantFormatVideoNode
Source code
178 179 180 181 182 183 184 185 186 187 |
|
retinex ¶
retinex(
clip: VideoNode,
sigma: Sequence[float] = [25, 80, 250],
lower_thr: float = 0.001,
upper_thr: float = 0.001,
fast: bool = True,
func: FuncExceptT | None = None,
) -> ConstantFormatVideoNode
Multi-Scale Retinex (MSR) implementation for dynamic range and contrast enhancement.
More information here.
Parameters:
-
clip
¶VideoNode
) –Input video clip.
-
sigma
¶Sequence[float]
, default:[25, 80, 250]
) –List of Gaussian sigmas for MSR. Using 3 scales (e.g., [25, 80, 250]) balances speed and quality.
-
lower_thr
¶float
, default:0.001
) –Lower threshold percentile for output normalization (0–1, exclusive). Affects shadow contrast.
-
upper_thr
¶float
, default:0.001
) –Upper threshold percentile for output normalization (0–1, exclusive). Affects highlight compression.
-
fast
¶bool
, default:True
) –Enables fast mode using downscaled approximation and simplifications. Default is True.
-
func
¶FuncExceptT | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
ConstantFormatVideoNode
–Processed luma-enhanced clip.
Source code
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 |
|
texture_mask ¶
texture_mask(
clip: VideoNode,
rady: int = 2,
radc: int | None = None,
blur: int | float = 8,
thr: float = 0.2,
stages: list[tuple[int, int]] = [(60, 2), (40, 4), (20, 2)],
points: list[tuple[bool, float]] = [
(False, 1.75),
(True, 2.5),
(True, 5),
(False, 10),
],
) -> ConstantFormatVideoNode
Source code
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 |
|