blockmatch ¶
Functions:
-
bm3d
–Block-Matching and 3D filtering (BM3D) is a state-of-the-art algorithm for image denoising.
-
wnnm
–Weighted Nuclear Norm Minimization Denoise algorithm.
BM3D ¶
BM3D(bm3d_func: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the bm3d function and extends its functionality.
It is not meant to be used directly.
Classes:
-
Backend
–Enum representing the available backends for running the BM3D plugin.
-
Profile
–Enum representing the available BM3D profiles, each with default parameter settings.
Methods:
-
__call__
–
Attributes:
-
matrix_opp2rgb
(list[float]
) –Matrix to convert OPP (Opponent) color space back to RGB color space.
-
matrix_rgb2opp
(list[float]
) –Matrix to convert RGB color space to OPP (Opponent) color space.
Source code
142 143 |
|
matrix_opp2rgb class-attribute
instance-attribute
¶
Matrix to convert OPP (Opponent) color space back to RGB color space.
matrix_rgb2opp class-attribute
instance-attribute
¶
Matrix to convert RGB color space to OPP (Opponent) color space.
Backend ¶
Bases: CustomEnum
Enum representing the available backends for running the BM3D plugin.
Methods:
-
resolve
–Resolves the appropriate BM3D backend to use based on availability and context.
Attributes:
-
AUTO
–Automatically selects the best available backend.
-
CPU
–Optimized CPU implementation using AVX and AVX2 intrinsics.
-
CUDA
–GPU implementation using NVIDIA CUDA.
-
CUDA_RTC
–GPU implementation using NVIDIA CUDA with NVRTC (runtime compilation).
-
HIP
–GPU implementation using AMD HIP.
-
OLD
–Reference VapourSynth-BM3D implementation.
-
SYCL
–GPU implementation using Intel SYCL.
-
plugin
(_VSPlugin
) –Returns the appropriate BM3D plugin based on the current backend.
AUTO class-attribute
instance-attribute
¶
AUTO = 'auto'
Automatically selects the best available backend. Selection priority: "CUDA_RTC" → "CUDA" → "HIP" → "SYCL" → "CPU" → "OLD". When the filter chain is executed within vspreview, the priority of "cuda_rtc" and "cuda" is reversed.
CPU class-attribute
instance-attribute
¶
CPU = 'bm3dcpu'
Optimized CPU implementation using AVX and AVX2 intrinsics.
CUDA_RTC class-attribute
instance-attribute
¶
CUDA_RTC = 'bm3dcuda_rtc'
GPU implementation using NVIDIA CUDA with NVRTC (runtime compilation).
plugin property
¶
plugin: _VSPlugin
Returns the appropriate BM3D plugin based on the current backend.
Returns:
-
_VSPlugin
–The corresponding BM3D plugin for the resolved backend.
resolve cached
¶
resolve() -> Backend
Resolves the appropriate BM3D backend to use based on availability and context.
If the current instance is not BM3D.Backend.AUTO, it returns itself. Otherwise, it attempts to select the best available backend.
Returns:
-
Backend
–The resolved BM3D.Backend to use for processing.
Raises:
-
CustomRuntimeError
–If no supported BM3D implementation is available on the system.
Source code
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 |
|
Profile ¶
Bases: CustomStrEnum
Enum representing the available BM3D profiles, each with default parameter settings.
For more detailed information on these profiles, refer to the original documentation
Methods:
-
basic_args
–Retrieves the arguments for the basic estimate step based on the specified radius.
-
final_args
–Retrieves the arguments for the final estimate step based on the specified radius.
Attributes:
-
FAST
–A profile optimized for maximum processing speed.
-
HIGH
–A profile focused on achieving high-precision denoising.
-
LOW_COMPLEXITY
–A profile designed for content with low-complexity noise.
-
NORMAL
–A neutral profile.
-
VERY_NOISY
–A profile tailored for handling very noisy content.
-
config
(MappingProxyType[str, MappingProxyType[str, MappingProxyType[str, Any]]]
) –Retrieves the configuration for each BM3D profile.
FAST class-attribute
instance-attribute
¶
FAST = 'fast'
A profile optimized for maximum processing speed.
HIGH class-attribute
instance-attribute
¶
HIGH = 'high'
A profile focused on achieving high-precision denoising.
LOW_COMPLEXITY class-attribute
instance-attribute
¶
LOW_COMPLEXITY = 'lc'
A profile designed for content with low-complexity noise.
VERY_NOISY class-attribute
instance-attribute
¶
VERY_NOISY = 'vn'
A profile tailored for handling very noisy content.
config cached
property
¶
config: MappingProxyType[str, MappingProxyType[str, MappingProxyType[str, Any]]]
Retrieves the configuration for each BM3D profile.
basic_args ¶
Retrieves the arguments for the basic estimate step based on the specified radius.
Parameters:
Returns:
Source code
441 442 443 444 445 446 447 448 |
|
final_args ¶
Retrieves the arguments for the final estimate step based on the specified radius.
Parameters:
Returns:
Source code
450 451 452 453 454 455 456 457 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code
145 146 |
|
UnsupportedProfileError ¶
Bases: CustomValueError
Raised when an unsupported profile is passed.
bm3d ¶
bm3d(
clip: VideoNode,
sigma: float | Sequence[float] = 0.5,
tr: int | Sequence[int | None] | None = None,
refine: int = 1,
profile: Profile = FAST,
pre: VideoNode | None = None,
ref: VideoNode | None = None,
backend: Backend = AUTO,
basic_args: dict[str, Any] | None = None,
final_args: dict[str, Any] | None = None,
**kwargs: Any
) -> ConstantFormatVideoNode
Block-Matching and 3D filtering (BM3D) is a state-of-the-art algorithm for image denoising.
More information at: - https://github.com/HomeOfVapourSynthEvolution/VapourSynth-BM3D/ - https://github.com/WolframRhodium/VapourSynth-BM3DCUDA
Example:
denoised = bm3d(clip, 1.25, 1, backend=bm3d.Backend.CUDA_RTC, ...)
Parameters:
-
clip
¶VideoNode
) –The clip to process. If using BM3D.Backend.OLD, the clip format must be YUV444 or RGB, as filtering is always performed in the OPPonent color space. If using another device type and the clip format is: - RGB -> Processed in OPP format (BM3D algorithm, aka
chroma=False
). - YUV444 -> Processed in YUV444 format (CBM3D algorithm, akachroma=True
). - GRAY -> Processed as-is. - YUVXXX -> Each plane is processed separately. -
sigma
¶float | Sequence[float]
, default:0.5
) –Strength of denoising. Valid range is [0, +inf). A sequence of up to 3 elements can be used to set different sigma values for the Y, U, and V channels. If fewer than 3 elements are given, the last value is repeated. Defaults to 0.5.
-
tr
¶int | Sequence[int | None] | None
, default:None
) –The temporal radius for denoising. Valid range is [1, 16]. Defaults to the radius defined by the profile.
-
refine
¶int
, default:1
) –Number of refinement steps. * 0 means basic estimate only. * 1 means basic estimate with one final estimate. * n means basic estimate refined with a final estimate n times.
-
profile
¶Profile
, default:FAST
) –The preset profile. Defaults to BM3D.Profile.FAST.
-
pre
¶VideoNode | None
, default:None
) –A pre-filtered clip for the basic estimate. It should be more suitable for block-matching than the input clip, and must be of the same format and dimensions. Either
pre
orref
can be specified, not both. Defaults to None. -
ref
¶VideoNode | None
, default:None
) –A clip to be used as the basic estimate. It replaces BM3D’s internal basic estimate and serves as the reference for the final estimate. Must be of the same format and dimensions as the input clip. Either
ref
orpre
can be specified, not both. Defaults to None. -
backend
¶Backend
, default:AUTO
) –The backend to use for processing. Defaults to BM3D.Backend.AUTO.
-
basic_args
¶dict[str, Any] | None
, default:None
) –Additional arguments to pass to the basic estimate step. Defaults to None.
-
final_args
¶dict[str, Any] | None
, default:None
) –Additional arguments to pass to the final estimate step. Defaults to None.
-
**kwargs
¶Any
, default:{}
) –Internal keyword arguments for testing purposes.
Returns:
-
ConstantFormatVideoNode
–Denoised clip.
Raises:
-
CustomValueError
–If both
pre
andref
are specified at the same time. -
UnsupportedProfileError
–If the VERY_NOISY profile is not supported by the selected device type.
-
UnsupportedVideoFormatError
–If the video format is not supported when using BM3D.Backend.OLD.
Source code
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 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 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 640 641 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 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
wnnm ¶
wnnm(
clip: VideoNode,
sigma: float | Sequence[float] = 3.0,
tr: int = 0,
refine: int = 0,
ref: VideoNode | None = None,
merge_factor: float = 0.1,
self_refine: bool = False,
planes: PlanesT = None,
**kwargs: Any
) -> VideoNode
Weighted Nuclear Norm Minimization Denoise algorithm.
Block matching, which is popularized by BM3D, finds similar blocks and then stacks together in a 3-D group. The similarity between these blocks allows details to be preserved during denoising.
In contrast to BM3D, which denoises the 3-D group based on frequency domain filtering, WNNM utilizes weighted nuclear norm minimization, a kind of low rank matrix approximation. Because of this, WNNM exhibits less blocking and ringing artifact compared to BM3D, but the computational complexity is much higher. This stage is called collaborative filtering in BM3D.
For more information, see the WNNM README.
Parameters:
-
clip
¶VideoNode
) –Clip to process.
-
sigma
¶float | Sequence[float]
, default:3.0
) –Strength of denoising, valid range is [0, +inf]. If a float is passed, this strength will be applied to every plane. Values higher than 4.0 are not recommended. Recommended values are [0.35, 1.0]. Default: 3.0.
-
refine
¶int
, default:0
) –The amount of iterations for iterative regularization. Default: 0.
-
tr
¶int
, default:0
) –Temporal radius. To enable spatial-only denoising, set this to 0. Higher values will rapidly increase filtering time and RAM usage. Default: 0.
-
ref
¶VideoNode | None
, default:None
) –Reference clip. Must be the same dimensions and format as input clip. Default: None.
-
merge_factor
¶float
, default:0.1
) –Merge amount of the last recalculation into the new one when performing iterative regularization.
-
self_refine
¶bool
, default:False
) –If True, the iterative recalculation step will use the result from the previous iteration as the reference clip
ref
instead of the original input. Default: False. -
planes
¶PlanesT
, default:None
) –Planes to process. If None, all planes. Default: None.
-
kwargs
¶Any
, default:{}
) –Additional arguments to be passed to the plugin.
Returns:
-
VideoNode
–Denoised clip.
Source code
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 |
|