Masking Functions

rvsfunc.masking.dehalo_mask

Lazy wrapper for making a very basic dehalo mask.

rvsfunc.masking.detail_mask

Generates a fairly basic detail mask, mostly for descaling purposes.

rvsfunc.masking.eoe_convolution

Convolution written by EoE for dvd.chromashifter()

rvsfunc.masking.fineline_mask

Generates a very fine mask for lineart protection.

rvsfunc.masking.scradit_mask

Basic detail and credit masking function borrowed from Scrad.

Different kinds of masking functions I either wrote or “borrowed”. These are generalized as much as possible, but some masking functions just exist for a very specific purpose. This is also my playground to mess with Expressions and convolutions, so expect some stuff to get added and removed infrequently and a fair few commits that state something along the lines of me complaining about broken code.

rvsfunc.masking.dehalo_mask(clip, maskgen=None, iter_out=2, iter_in=-1, inner=False, outer=False)

Lazy wrapper for making a very basic dehalo mask.

Expects a YUV clip. No idea what happens when anything else is passed, and it’s not my issue to figure that out either. Make sure to handle any conversions properly before calling this function with a clip.

Parameters
  • clip (VideoNode) – The clip to generate the mask for

  • maskgen (Optional[Callable[[VideoNode], VideoNode]]) – The masking function to call. Defaults to Prewitt.

  • iter_out (int) – Amount of times to iterate expansion for the outer mask Defaults to 2, the standard size

  • iter_in (int) – Amount of times to iterate impansion for the inner mask Defaults to iter_out + 1.

  • inner (bool) – Returns the inner mask for checking.

  • outer (bool) – Returns the outer mask for checking.

Return type

VideoNode

rvsfunc.masking.detail_mask(source, rescaled, thresh=0.05)

Generates a fairly basic detail mask, mostly for descaling purposes.

This is mostly used to pick up on detail lost in edgecase.questionable_rescale() as per Zastin’s original script. Catches most if not all elements in a different native resolution

Parameters
  • source (VideoNode) – The clip to generate the mask for.

  • rescaled (VideoNode) – The descaled and re-upscaled clip where detail was lost.

  • thresh (float) – The threshold for binarizing the detail mask

Return type

VideoNode

rvsfunc.masking.eoe_convolution(clip)

Convolution written by EoE for dvd.chromashifter()

Return type

VideoNode

rvsfunc.masking.finedehalo_mask(clip, thresh=24320, *, chroma=False)

Dehalo mask based on fineline_mask() for protecting small things.

A masking function designed to protect textures and very thin linework and very fine detail, like textures, when performing more aggressive forms of filtering. Fairly large values are required for the threshold because all internal processing is done in 16 bit. If threshold values are in the 8-bit range, they will be adjusted to 16-bit values. The returned mask is the same depth as the input clip.

Parameters
  • clip (VideoNode) – The clip to generate the mask for.

  • thresh (int) – The threshold value used for fineline_mask(). Don’t forget to scale the value for 16-bit video.

  • chroma (bool) – Whether or not to mask chroma.

Return type

VideoNode

rvsfunc.masking.fineline_mask(clip, thresh=95)

Generates a very fine mask for lineart protection. Not perfect yet

The generated mask is GRAY8, keep this in mind for conversions.

Parameters
  • clip (VideoNode) – The clip to generate the mask for.

  • thresh (int) – The threshold for the binarization step.

Return type

VideoNode

rvsfunc.masking.scradit_mask(src_luma, rescaled_luma, absthresh=0.060, iters=4)

Basic detail and credit masking function borrowed from Scrad.

Changed it to be used in a more generic manner, but the core stuff and logic comes from him. Or wherever he got it. Geared towards catching very light detail in a different native resolution than the rest of the video. Returns a 32 bit (GrayS) mask.

Parameters
  • src_luma (VideoNode) – Luma plane of the source. If it has more planes, the luma plane will be extracted.

  • rescaled_luma (VideoNode) – Luma plane of the rescaled video. If it has more planes, the luma plane will be extracted.

  • absthresh (float) – The threshold for binarizing the mask with.

  • iters (int) – How often to iterate Maximum and Inflate calls.

Return type

VideoNode