mask ¶
This module implements dehalo functions with complex masking abilities.
Functions:
-
fine_dehalo
–Halo removal function based on
dehalo_alpha
, enhanced with additional masking and optional contra-sharpening -
fine_dehalo2
–Halo removal function for 2nd order halos.
FineDehalo ¶
FineDehalo(fine_dehalo: Callable[P, R])
Bases: Generic[P, R]
Class decorator that wraps the fine_dehalo function and extends its functionality.
It is not meant to be used directly.
Classes:
-
Masks
–Class for creating and storing intermediate masks used in the
fine_dehalo
function.
Methods:
Attributes:
Source code in vsdehalo/mask.py
63 64 |
|
Masks ¶
Masks(
clip: VideoNode,
rx: int = 2,
ry: int | None = None,
edgemask: MaskLike = Robinson3,
thmi: int = 80,
thma: int = 128,
thlimi: int = 50,
thlima: int = 100,
exclude: bool = True,
edgeproc: float = 0.0,
planes: Planes = 0,
func: FuncExcept | None = None,
)
Bases: Mapping[str, ConstantFormatVideoNode]
, vs_object
Class for creating and storing intermediate masks used in the fine_dehalo
function.
Each step of the masking pipeline is stored with a descriptive key, allowing for debugging or further processing.
Initialize the mask generation process.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
rx
¶int
, default:2
) –Horizontal radius for halo removal.
-
ry
¶int | None
, default:None
) –Vertical radius for halo removal. Defaults to
rx
if not set. -
edgemask
¶MaskLike
, default:Robinson3
) –Edge detection object to use. Defaults to
Robinson3
. -
thmi
¶int
, default:80
) –Minimum threshold for sharp edge selection; isolates only the strongest (line-like) edges.
-
thma
¶int
, default:128
) –Maximum threshold for sharp edge selection; filters out weaker edges.
-
thlimi
¶int
, default:50
) –Minimum threshold for including edges that were previously ignored.
-
thlima
¶int
, default:100
) –Maximum threshold for the inclusion of additional, less distinct edges.
-
exclude
¶bool
, default:True
) –Whether to exclude edges that are too close together.
-
edgeproc
¶float
, default:0.0
) –If greater than 0, adds the edge mask into the final processing. Defaults to 0.0.
-
planes
¶Planes
, default:0
) –Planes to process.
-
func
¶FuncExcept | None
, default:None
) –An optional function to use for error handling.
Attributes:
-
EDGES
(ConstantFormatVideoNode
) – -
IGNORE_DETAILS
(ConstantFormatVideoNode
) – -
LARGE_EDGES
(ConstantFormatVideoNode
) – -
MAIN
(ConstantFormatVideoNode
) – -
SHARP_EDGES
(ConstantFormatVideoNode
) – -
SHRINK
(ConstantFormatVideoNode
) – -
SHRINK_EDGES_EXCL
(ConstantFormatVideoNode
) –
Source code in vsdehalo/mask.py
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 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 |
|
__call__ ¶
__call__(*args: args, **kwargs: kwargs) -> R
Source code in vsdehalo/mask.py
66 67 |
|
mask ¶
mask(
clip: VideoNode,
rx: int = 2,
ry: int | None = None,
edgemask: MaskLike = Robinson3,
thmi: int = 80,
thma: int = 128,
thlimi: int = 50,
thlima: int = 100,
exclude: bool = True,
edgeproc: float = 0.0,
planes: Planes = 0,
func: FuncExcept | None = None,
) -> ConstantFormatVideoNode
The fine_dehalo mask.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
rx
¶int
, default:2
) –Horizontal radius for halo removal.
-
ry
¶int | None
, default:None
) –Vertical radius for halo removal. Defaults to
rx
if not set. -
edgemask
¶MaskLike
, default:Robinson3
) –Edge detection object to use. Defaults to
Robinson3
. -
thmi
¶int
, default:80
) –Minimum threshold for sharp edge selection; isolates only the strongest (line-like) edges.
-
thma
¶int
, default:128
) –Maximum threshold for sharp edge selection; filters out weaker edges.
-
thlimi
¶int
, default:50
) –Minimum threshold for including edges that were previously ignored.
-
thlima
¶int
, default:100
) –Maximum threshold for the inclusion of additional, less distinct edges.
-
exclude
¶bool
, default:True
) –Whether to exclude edges that are too close together.
-
edgeproc
¶float
, default:0.0
) –If greater than 0, adds the edge mask into the final processing. Defaults to 0.0.
-
planes
¶Planes
, default:0
) –Planes to process.
-
func
¶FuncExcept | None
, default:None
) –An optional function to use for error handling.
Returns:
-
ConstantFormatVideoNode
–Mask clip.
Source code in vsdehalo/mask.py
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 |
|
fine_dehalo ¶
fine_dehalo(
clip: VideoNode,
blur: (
IterArr[float]
| VSFunctionPlanesArgs
| tuple[float | list[float] | VSFunctionPlanesArgs, ...]
) = GAUSS(sigma=1.4),
lowsens: IterArr[float] = 50.0,
highsens: IterArr[float] = 50.0,
ss: float | tuple[float, ...] = 1.5,
darkstr: IterArr[float] = 0.0,
brightstr: IterArr[float] = 1.0,
rx: int = 2,
ry: int | None = None,
edgemask: MaskLike = Robinson3,
thmi: int = 80,
thma: int = 128,
thlimi: int = 50,
thlima: int = 100,
exclude: bool = True,
edgeproc: float = 0.0,
contra: float = 0.0,
pre_ss: int = 1,
planes: Planes = 0,
attach_masks: bool = False,
func: FuncExcept | None = None,
**kwargs: Any
) -> VideoNode
Halo removal function based on dehalo_alpha
, enhanced with additional masking and optional contra-sharpening to better preserve important line detail while effectively reducing halos.
The parameter ss
can be configured per iteration while blur
, lowsens
, highsens
, darkstr
and brightstr
can be configured per plane and per iteration. You can specify:
- A single value: applies to all iterations and all planes.
- A tuple of values: interpreted as iteration-wise.
- A list inside the tuple: interpreted as per-plane for a specific iteration.
For example
blur=(1.4, [1.4, 1.65], [1.5, 1.4, 1.45])
implies 3 iterations: - 1st: 1.4 for all planes - 2nd: 1.4 for luma, 1.65 for both chroma planes - 3rd: 1.5 for luma, 1.4 for U, 1.45 for V
Example usage
dehalo = fine_dehalo(clip, (2.0, 1.4), brightstr=(0.85, 0.25))
# Getting the masks of the last fine_dehalo call:
dehalo_mask = fine_dehalo.masks.MAIN
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
blur
¶IterArr[float] | VSFunctionPlanesArgs | tuple[float | list[float] | VSFunctionPlanesArgs, ...]
, default:GAUSS(sigma=1.4)
) –Standard deviation of the Gaussian kernel if float or custom blurring function to use in place of the default implementation.
-
lowsens
¶IterArr[float]
, default:50.0
) –Lower sensitivity threshold — dehalo is fully applied below this value.
-
highsens
¶IterArr[float]
, default:50.0
) –Upper sensitivity threshold — dehalo is completely skipped above this value.
-
ss
¶float | tuple[float, ...]
, default:1.5
) –Supersampling factor to reduce aliasing artifacts.
-
darkstr
¶IterArr[float]
, default:0.0
) –Strength factor for suppressing dark halos.
-
brightstr
¶IterArr[float]
, default:1.0
) –Strength factor for suppressing bright halos.
-
rx
¶int
, default:2
) –Horizontal radius for halo removal.
-
ry
¶int | None
, default:None
) –Vertical radius for halo removal. Defaults to
rx
if not set. -
edgemask
¶MaskLike
, default:Robinson3
) –Edge detection object to use. Defaults to
Robinson3
. -
thmi
¶int
, default:80
) –Minimum threshold for sharp edge selection; isolates only the strongest (line-like) edges.
-
thma
¶int
, default:128
) –Maximum threshold for sharp edge selection; filters out weaker edges.
-
thlimi
¶int
, default:50
) –Minimum threshold for including edges that were previously ignored.
-
thlima
¶int
, default:100
) –Maximum threshold for the inclusion of additional, less distinct edges.
-
exclude
¶bool
, default:True
) –Whether to exclude edges that are too close together.
-
edgeproc
¶float
, default:0.0
) –If greater than 0, adds the edge mask into the final processing. Defaults to 0.0.
-
contra
¶float
, default:0.0
) –Contra-sharpening level in [contrasharpening_dehalo][vsdehalo.contra.contrasharpening_dehalo].
-
pre_ss
¶int
, default:1
) –Scaling factor for supersampling before processing. If > 1, supersamples the clip with NNEDI3, applies dehalo processing, and then downscales back with Point.
-
planes
¶Planes
, default:0
) –Planes to process.
-
attach_masks
¶bool
, default:False
) –Stores the masks as frame properties in the output clip. The prop names are
FineDehaloMask
+ the masking step. -
func
¶FuncExcept | None
, default:None
) –An optional function to use for error handling.
-
**kwargs
¶Any
, default:{}
) –Additionnal advanced parameters.
Returns:
-
VideoNode
–Dehaloed clip.
Source code in vsdehalo/mask.py
279 280 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 323 324 325 326 327 328 329 330 331 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
fine_dehalo2 ¶
fine_dehalo2(
clip: VideoNode,
mode: OneDimConvMode = HV,
radius: int = 2,
mask_radius: int = 2,
brightstr: float = 1.0,
darkstr: float = 1.0,
dark: bool | None = True,
*,
attach_masks: bool = False
) -> VideoNode
Halo removal function for 2nd order halos.
Parameters:
-
clip
¶VideoNode
) –Source clip.
-
mode
¶OneDimConvMode
, default:HV
) –Horizontal/Vertical or both ways.
-
radius
¶int
, default:2
) –Radius for the fixing convolution.
-
mask_radius
¶int
, default:2
) –Radius for mask growing.
-
brightstr
¶float
, default:1.0
) –Strength factor for bright halos.
-
darkstr
¶float
, default:1.0
) –Strength factor for dark halos.
-
dark
¶bool | None
, default:True
) –Whether to filter for dark or bright haloing. None for disable merging with source clip.
-
attach_masks
¶bool
, default:False
) –Stores the masks as frame properties in the output clip. The prop names are
FineDehalo2MaskV
andFineDehalo2MaskH
.
Returns:
-
VideoNode
–Dehaloed clip.
Source code in vsdehalo/mask.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 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 |
|