YRangeMask
From Avisynth wiki
| Abstract | |
|---|---|
| Author | Chikuzen |
| Version | 2016/01/24 |
| Download | mt_yrangemask.avsi |
| Category | Masking |
| License | |
| Discussion | |
Contents |
Description
AviSynth script to create a mask by specifying the range of the brightness.
mt_yrangemask is a script implementation of the old YRangeMask plugin by Putin. The script version is much faster and supports additional colorspaces.
Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: Y8, YV12, YV16, YV24, YV411
Required Plugins
Latest versions of the following filters are recommended unless stated otherwise.
Syntax and Parameters
- mt_yrangemask (clip , int "min_y", int "fade_min_y", int "max_y", int "fade_max_y", bool "invert")
- clip =
- Input clip.
- clip =
- int min_y = 0
- Minimum threshold.
- int min_y = 0
- int fade_min_y = 0
- How many minimum pixels to fade.
- int fade_min_y = 0
- int max_y = 0
- Maximum threshold.
- int max_y = 0
- int fade_max_y = 0
- How many maximum pixels to fade.
- int fade_max_y = 0
- bool invert = false
- Set to
trueto invert the mask.
- Set to
- bool invert = false
Script
function mt_yrangemask(clip clip, int "min_y", int "fade_min_y", int "max_y", int "fade_max_y", bool "invert")
{
assert(clip.IsPlanar(), "clip is not planar format")
min = default(min_y, 0)
max = default(max_y, 0)
assert(min >= 0 || min < 256 || max < 256, "Specify in the range from 0 to 255")
assert(min <= max, "min_y must be less than or equal to max_y")
fmin = default(fade_min_y, 0)
fmax = default(fade_max_y, 0)
assert((fmin + fmax) <= (max - min), "'fade_min_y + fade_max_y' should be less than or equal to 'max_y - min_y'")
min = string(min - 1)
max = string(max + 1)
fmin = string(fmin + 1)
fmax = string(fmax)
invert = default(invert, false)
#expr = 255 / (x < max - fmax ? fmin / (x - min) : (fmax + 1) / (max - x))
#expr = invert ? 255 - expr : expr
expr = "255 / (x < " + max + " - " + fmax + " ? " + fmin + " / (x - " + min + ") : (" + fmax + " + 1) / (" + max + " - x))"
expr = (invert ? "255 - " : "") + expr
return clip.mt_lut(mt_polish(expr), chroma="0")
}
Examples
Masked areas and the effect of the fade parameters.
Note: illustration was taken from YRangeMask docs.
1) mt_yrangemask(min_y=16, fade_min_y=0, max_y=80, fade_max_y=0)2) mt_yrangemask(min_y=16, fade_min_y=4, max_y=80, fade_max_y=16)
Another example:
BlankClip(length=10000, width=1920, height=1080, pixel_type="YV12") mt_lutspa(mode="relative", expr="x 256 *", chroma="128") mt_yrangemask(min_y=16, fade_min_y=4, max_y=80, fade_max_y=16, invert=true)
Changelog
Version Date Changes
2016/01/24 - mt_yrangemask: MaskTools2 script reimplementation by Chikuzen v0.03 2012/06/02 - ? v0.02 2012/05/28 - ? v0.01 2012/05/01 - initial release
Archived Downloads
- Note: YRangeMask is an AviSynth 2.5 closed source plugin. Not recommended! The script implementation is faster and supports additional colorspaces.
| Version | Download |
|---|---|
| v0.03 | yrangemask003.rar |
| v0.02 | yrangemask002.rar |
External Links
- potatosub's blog - Using WarpSharp + YRangeMask (Japanese).
- csbarn.blogspot.com - mt_yrangemask script, uses MaskTools2 for much better performance (Japanese).
Back to External Filters ←
