blur ¶
Functions:
-
bilateral
–Applies a bilateral filter for edge-preserving and noise-reducing smoothing.
-
box_blur
–Applies a box blur to the input clip.
-
flux_smooth
–FluxSmoothT examines each pixel and compares it to the corresponding pixel in the previous and next frames.
-
gauss_blur
–Applies Gaussian blur to a clip, supporting spatial and temporal modes, and per-plane control.
-
guided_filter
– -
median_blur
–Applies a median blur to the clip using spatial or temporal neighborhood.
-
min_blur
–Combines binomial (Gaussian-like) blur and median filtering for a balanced smoothing effect.
-
sbr
–A helper function for high-pass filtering a blur difference, inspired by an AviSynth script by Didée.
-
side_box_blur
–
Bilateral ¶
Bilateral(bilateral_func: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the bilateral function and extends its functionality.
It is not meant to be used directly.
Classes:
-
Backend
–Enum specifying which backend implementation of the bilateral filter to use.
Methods:
-
__call__
–
Source code in vsrgtools/blur.py
553 554 |
|
Backend ¶
Bases: CustomStrEnum
Enum specifying which backend implementation of the bilateral filter to use.
Methods:
-
Bilateral
–Applies the bilateral filter using the plugin associated with the selected backend.
Attributes:
-
CPU
–Uses
vszip.Bilateral
— a fast, CPU-based implementation written in Zig. -
GPU
–Uses
bilateralgpu.Bilateral
— a CUDA-based GPU implementation. -
GPU_RTC
–Uses
bilateralgpu_rtc.Bilateral
— a CUDA-based GPU implementation with runtime shader compilation.
CPU class-attribute
instance-attribute
¶
CPU = 'vszip'
Uses vszip.Bilateral
— a fast, CPU-based implementation written in Zig.
GPU class-attribute
instance-attribute
¶
GPU = 'bilateralgpu'
Uses bilateralgpu.Bilateral
— a CUDA-based GPU implementation.
GPU_RTC class-attribute
instance-attribute
¶
GPU_RTC = 'bilateralgpu_rtc'
Uses bilateralgpu_rtc.Bilateral
— a CUDA-based GPU implementation with runtime shader compilation.
Bilateral ¶
Applies the bilateral 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
–Bilaterally filtered clip.
Source code in vsrgtools/blur.py
579 580 581 582 583 584 585 586 587 588 589 590 591 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code in vsrgtools/blur.py
556 557 |
|
GaussBlur ¶
GaussBlur(gauss_blur: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the gauss_blur function and extends its functionality.
It is not meant to be used directly.
Methods:
-
__call__
– -
from_radius
–Applies Gaussian blur to a clip from an intuitive radius.
-
get_radius
–Compute the radius required for a given sigma value.
-
get_sigma
–Generate a Gaussian sigma value from an intuitive radius.
Source code in vsrgtools/blur.py
143 144 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code in vsrgtools/blur.py
146 147 |
|
from_radius staticmethod
¶
from_radius(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: OneDimConvMode | TempConvMode = HV,
planes: Planes = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Applies Gaussian blur to a clip from an intuitive radius.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
radius
¶int | Sequence[int]
, default:1
) –Size of the kernel in each direction. Automatically determined if not specified.
-
mode
¶OneDimConvMode | TempConvMode
, default:HV
) –Convolution mode (horizontal, vertical, both, or temporal). Defaults to HV.
-
planes
¶Planes
, default:None
) –Planes to process. Defaults to all.
-
**kwargs
¶Any
, default:{}
) –Additional arguments passed to the resizer or blur kernel. Specifying
_fast=True
enables fast approximation.
Returns:
-
ConstantFormatVideoNode
–Blurred clip.
Source code in vsrgtools/blur.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
get_radius staticmethod
¶
Compute the radius required for a given sigma value.
Parameters:
Returns:
-
int
–Radius.
Source code in vsrgtools/blur.py
188 189 190 191 192 193 194 195 196 197 198 199 |
|
get_sigma staticmethod
¶
Generate a Gaussian sigma value from an intuitive radius.
This is a shortcut that converts a blur radius to a corresponding sigma value.
Parameters:
Returns:
-
float
–Gaussian sigma value
Source code in vsrgtools/blur.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
GuidedFilter ¶
GuidedFilter(guided_filter_func: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the guided_filter function and extends its functionality.
It is not meant to be used directly.
Classes:
-
Mode
–
Methods:
-
__call__
–
Source code in vsrgtools/blur.py
694 695 |
|
bilateral ¶
bilateral(
clip: VideoNode,
ref: VideoNode | None = None,
sigmaS: float | Sequence[float] | None = None,
sigmaR: float | Sequence[float] | None = None,
backend: Backend = CPU,
**kwargs: Any
) -> ConstantFormatVideoNode
Applies a bilateral filter for edge-preserving and noise-reducing smoothing.
This filter replaces each pixel with a weighted average of nearby pixels based on both spatial distance and pixel intensity similarity. It can be used for joint (cross) bilateral filtering when a reference clip is given.
Example
blurred = bilateral(clip, ref, 3.0, 0.02, backend=bilateral.Backend.CPU)
For more details, see:
- https://github.com/dnjulek/vapoursynth-zip/wiki/Bilateral
- https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Bilateral
- https://github.com/WolframRhodium/VapourSynth-BilateralGPU
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
ref
¶VideoNode | None
, default:None
) –Optional reference clip for joint bilateral filtering.
-
sigmaS
¶float | Sequence[float] | None
, default:None
) –Spatial sigma (controls the extent of spatial smoothing). Can be a float or per-plane list.
-
sigmaR
¶float | Sequence[float] | None
, default:None
) –Range sigma (controls sensitivity to intensity differences). Can be a float or per-plane list.
-
backend
¶Backend
, default:CPU
) –Backend implementation to use.
-
**kwargs
¶Any
, default:{}
) –Additional arguments forwarded to the backend-specific implementation.
Returns:
-
ConstantFormatVideoNode
–Bilaterally filtered clip.
Source code in vsrgtools/blur.py
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
|
box_blur ¶
box_blur(
clip: VideoNode,
radius: int | Sequence[int] = 1,
passes: int = 1,
mode: OneDimConvMode | TempConvMode = HV,
planes: Planes = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Applies a box blur to the input clip.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
radius
¶int | Sequence[int]
, default:1
) –Blur radius (spatial or temporal) Can be a int or a list for per-plane control. Defaults to 1
-
passes
¶int
, default:1
) –Number of times the blur is applied. Defaults to 1
-
mode
¶OneDimConvMode | TempConvMode
, default:HV
) –Convolution mode (horizontal, vertical, both, or temporal). Defaults to HV.
-
planes
¶Planes
, default:None
) –Planes to process. Defaults to all.
Raises:
-
CustomValueError
–If square convolution mode is specified, which is unsupported.
Returns:
-
ConstantFormatVideoNode
–Blurred clip.
Source code in vsrgtools/blur.py
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 |
|
flux_smooth ¶
flux_smooth(
clip: VideoNode,
temporal_threshold: float | Sequence[float] = 7.0,
spatial_threshold: float | Sequence[float] | None = None,
planes: Planes = None,
scalep: bool = True,
) -> ConstantFormatVideoNode
FluxSmoothT examines each pixel and compares it to the corresponding pixel in the previous and next frames. Smoothing occurs if both the previous frame's value and the next frame's value are greater, or if both are less than the value in the current frame.
Smoothing is done by averaging the pixel from the current frame with the pixels from the previous and/or next frames, if they are within temporal_threshold.
FluxSmoothST does the same as FluxSmoothT, except the pixel's eight neighbours from the current frame are also included in the average, if they are within spatial_threshold.
The first and last rows and the first and last columns are not processed by FluxSmoothST.
Parameters:
-
clip
¶VideoNode
) –Clip to process.
-
temporal_threshold
¶float | Sequence[float]
, default:7.0
) –Temporal neighbour pixels within this threshold from the current pixel are included in the average. Can be specified as an array, with values corresonding to each plane of the input clip. A negative value (such as -1) indicates that the plane should not be processed and will be copied from the input clip.
-
spatial_threshold
¶float | Sequence[float] | None
, default:None
) –Spatial neighbour pixels within this threshold from the current pixel are included in the average. A negative value (such as -1) indicates that the plane should not be processed and will be copied from the input clip.
-
planes
¶Planes
, default:None
) –Which planes to process. Default to all.
-
scalep
¶bool
, default:True
) –Parameter scaling. If set to true, all threshold values will be automatically scaled from 8-bit range (0-255) to the corresponding range of the input clip's bit depth.
Returns:
-
ConstantFormatVideoNode
–Smoothed clip.
Source code in vsrgtools/blur.py
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
|
gauss_blur ¶
gauss_blur(
clip: VideoNode,
sigma: float | Sequence[float] = 0.5,
radius: int | None = None,
mode: OneDimConvMode | TempConvMode = HV,
planes: Planes = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Applies Gaussian blur to a clip, supporting spatial and temporal modes, and per-plane control.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
sigma
¶float | Sequence[float]
, default:0.5
) –Standard deviation of the Gaussian kernel. Can be a float or a list for per-plane control.
-
radius
¶int | None
, default:None
) –Size of the kernel in each direction. Automatically determined if not specified.
-
mode
¶OneDimConvMode | TempConvMode
, default:HV
) –Convolution mode (horizontal, vertical, both, or temporal). Defaults to HV.
-
planes
¶Planes
, default:None
) –Planes to process. Defaults to all.
-
**kwargs
¶Any
, default:{}
) –Additional arguments passed to the resizer or blur kernel. Specifying
_fast=True
enables fast approximation.
Raises:
-
CustomValueError
–If square convolution mode is specified, which is unsupported.
Returns:
-
ConstantFormatVideoNode
–Blurred clip.
Source code in vsrgtools/blur.py
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 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
guided_filter ¶
guided_filter(
clip: VideoNode,
guidance: VideoNode | None = None,
radius: int | Sequence[int] | None = None,
thr: float | Sequence[float] = 1 / 3,
mode: Mode = GRADIENT,
use_gauss: bool = False,
planes: Planes = None,
down_ratio: int = 0,
downscaler: ScalerLike = Point,
upscaler: ScalerLike = Bilinear,
) -> VideoNode
Source code in vsrgtools/blur.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 |
|
median_blur ¶
median_blur(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: SpatialConvMode = SQUARE,
planes: Planes = None,
*,
func: FuncExcept | None = None
) -> ConstantFormatVideoNode
median_blur(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: Literal[SQUARE] = ...,
planes: Planes = None,
smart: Literal[True] = ...,
threshold: float | Sequence[float] | None = None,
scalep: bool = True,
*,
func: FuncExcept | None = None
) -> ConstantFormatVideoNode
median_blur(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: ConvMode = SQUARE,
planes: Planes = None,
smart: bool = False,
threshold: float | Sequence[float] | None = None,
scalep: bool = True,
scenechange: bool = False,
func: FuncExcept | None = None,
) -> ConstantFormatVideoNode
Applies a median blur to the clip using spatial or temporal neighborhood.
- In temporal mode, each pixel is replaced by the median across multiple frames.
- In spatial modes, each pixel is replaced with the median of its 2D neighborhood.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
radius
¶int | Sequence[int]
, default:1
) –Blur radius per plane (list) or uniform radius (int). Only int is allowed in temporal mode.
-
mode
¶ConvMode
, default:SQUARE
) –Convolution mode. Defaults to SQUARE.
-
planes
¶Planes
, default:None
) –Planes to process. Defaults to all.
-
smart
¶bool
, default:False
) –Enable Smart Median by zsmooth, thresholded based on a modified form of variance.
-
threshold
¶float | Sequence[float] | None
, default:None
) –The variance threshold when
smart=True
. Pixels with a variance under the threshold are smoothed, and over the threshold are returned as is. -
scalep
¶bool
, default:True
) –Parameter scaling when
smart=True
. If True, all threshold values will be automatically scaled from 8-bit range (0-255) to the corresponding range of the input clip's bit depth. -
scenechange
¶bool
, default:False
) –If True, avoid averaging frames over scene changes. The user must first invoke sc_detect.
-
func
¶FuncExcept | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Raises:
-
CustomValueError
–If a list is passed for radius in temporal mode, which is unsupported or if smart=True and mode != ConvMode.SQUARE.
Returns:
-
ConstantFormatVideoNode
–Median-blurred video clip.
Source code in vsrgtools/blur.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
min_blur ¶
min_blur(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: tuple[ConvMode, ConvMode] = (HV, SQUARE),
planes: Planes = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Combines binomial (Gaussian-like) blur and median filtering for a balanced smoothing effect.
This filter blends the input clip with both a binomial blur and a median blur to achieve a "best of both worlds" result — combining the edge-preserving nature of median filtering with the smoothness of Gaussian blur. The effect is somewhat reminiscent of a bilateral filter.
Original concept: http://avisynth.nl/index.php/MinBlur
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
radius
¶int | Sequence[int]
, default:1
) –Radius of blur to apply. Can be a single int or a list for per-plane control.
-
mode
¶tuple[ConvMode, ConvMode]
, default:(HV, SQUARE)
) –A tuple of two convolution modes: - First element: mode for binomial blur. - Second element: mode for median blur. Defaults to (HV, SQUARE).
-
planes
¶Planes
, default:None
) –Planes to process. Defaults to all.
-
**kwargs
¶Any
, default:{}
) –Additional arguments passed to the binomial blur.
Returns:
-
ConstantFormatVideoNode
–Clip with MinBlur applied.
Source code in vsrgtools/blur.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
sbr ¶
sbr(
clip: VideoNode,
radius: int | Sequence[int] = 1,
mode: ConvMode = HV,
blur: _SbrBlurT | VideoNode = BINOMIAL,
blur_diff: _SbrBlurT = BINOMIAL,
planes: Planes = None,
*,
func: FuncExcept | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
A helper function for high-pass filtering a blur difference, inspired by an AviSynth script by Didée. https://forum.doom9.org/showthread.php?p=1584186#post1584186
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
radius
¶int | Sequence[int]
, default:1
) –Specifies the size of the blur kernels if
blur
orblur_diff
is a BlurMatrix enum. Default to 1. -
mode
¶ConvMode
, default:HV
) –Specifies the convolution mode. Defaults to horizontal + vertical.
-
blur
¶_SbrBlurT | VideoNode
, default:BINOMIAL
) –Blur kernel to apply to the original clip. Defaults to binomial.
-
blur_diff
¶_SbrBlurT
, default:BINOMIAL
) –Blur kernel to apply to the difference clip. Defaults to binomial.
-
planes
¶Planes
, default:None
) –Which planes to process. Defaults to all.
-
func
¶FuncExcept | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
-
**kwargs
¶Any
, default:{}
) –Additional arguments passed to blur kernel call.
Returns:
-
ConstantFormatVideoNode
–Sbr'd clip.
Source code in vsrgtools/blur.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
side_box_blur ¶
Source code in vsrgtools/blur.py
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 |
|