YRangeMask
From Avisynth wiki
(Difference between revisions)
m (link) |
(update documentation to chikuzen's mt_yrangemask script) |
||
| Line 1: | Line 1: | ||
| − | {{FilterCat4|External_filters| | + | {{FilterCat4|External_filters|Scripts|Adjustment_filters|Masking}} |
{{Filter3 | {{Filter3 | ||
| − | | {{Author/ | + | | {{Author/Chikuzen}} |
| − | | | + | | 2016/01/24 |
| − | |[ | + | |[[YRangeMask#Script|mt_yrangemask.avsi]] |
| Masking | | Masking | ||
| − | | | + | | |
|}} | |}} | ||
| − | |||
== Description == | == Description == | ||
| − | AviSynth | + | AviSynth script to create a mask by specifying the range of the brightness.<br> |
| + | <code>mt_yrangemask</code> is a script reimplementation of the old YRangeMask plugin by Putin. The script version is much faster and supports additional colorspaces. | ||
<br> | <br> | ||
<br> | <br> | ||
| − | |||
== Requirements == | == Requirements == | ||
| − | * AviSynth | + | * [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6] |
| − | * Supported color formats: [[YV12]] | + | * [x64]: [[AviSynth+]] |
| − | + | * Supported color formats: [[Y8]], [[YV12]], [[YV16]], [[YV24]], [[YV411]] | |
| − | + | <br> | |
| + | ==== Required Plugins ==== | ||
| + | Latest versions of the following filters are recommended unless stated otherwise.<br> | ||
| + | *[[MaskTools2]] | ||
<br> | <br> | ||
== [[Script variables|Syntax and Parameters]] == | == [[Script variables|Syntax and Parameters]] == | ||
| − | :{{Template:FuncDef| | + | :{{Template:FuncDef|mt_yrangemask (clip , int "min_y", int "fade_min_y", int "max_y", int "fade_max_y", bool "invert")}} |
<br> | <br> | ||
::{{Par2| |clip| }} | ::{{Par2| |clip| }} | ||
| Line 41: | Line 43: | ||
:::Set to <code>true</code> to invert the mask. | :::Set to <code>true</code> to invert the mask. | ||
<br> | <br> | ||
| + | ==Script== | ||
| + | <pre> | ||
| + | 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") | ||
| + | } | ||
| + | </pre> | ||
| + | <br> | ||
== Examples == | == Examples == | ||
| − | Masked areas and the effect of the fade parameters. | + | Masked areas and the effect of the fade parameters.<br> |
| + | Note: illustration was taken from YRangeMask docs.<br> | ||
| + | <code>1) mt_yrangemask(min_y=16, fade_min_y=0, max_y=80, fade_max_y=0)</code><br><code>2) mt_yrangemask(min_y=16, fade_min_y=4, max_y=80, fade_max_y=16)</code> | ||
[[File:yrangemask.png]] | [[File:yrangemask.png]] | ||
| − | |||
| − | |||
| + | Another example: | ||
| + | <pre> | ||
| + | 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) | ||
| + | </pre> | ||
| + | <br> | ||
== Changelog == | == Changelog == | ||
Version Date Changes<br> | Version Date Changes<br> | ||
| − | v0.03 | + | 2016/01/24 - mt_yrangemask: MaskTools2 script reimplementation by Chikuzen |
| − | v0.02 | + | v0.03 2012/06/02 - ? |
| − | v0.01 | + | v0.02 2012/05/28 - ? |
| + | v0.01 2012/05/01 - initial release | ||
<br> | <br> | ||
== Archived Downloads == | == Archived Downloads == | ||
| − | {| class="wikitable" border="1"; width=" | + | *Note: YRangeMask is an AviSynth 2.5 closed source plugin. '''Not recommended!''' The script implementation is faster and supports additional colorspaces. |
| + | {| class="wikitable" border="1"; width="400px" | ||
|- | |- | ||
!!width="100px"| Version | !!width="100px"| Version | ||
!!width="150px"| Download | !!width="150px"| Download | ||
| − | |||
|- | |- | ||
!v0.03 | !v0.03 | ||
| − | |||
|[http://web.archive.org/web/20150510140334/http://putin999.web.fc2.com/yrangemask003.rar yrangemask003.rar] | |[http://web.archive.org/web/20150510140334/http://putin999.web.fc2.com/yrangemask003.rar yrangemask003.rar] | ||
|- | |- | ||
!v0.02 | !v0.02 | ||
| − | |||
|[http://web.archive.org/web/20150510140330/http://putin999.web.fc2.com/yrangemask002.rar yrangemask002.rar] | |[http://web.archive.org/web/20150510140330/http://putin999.web.fc2.com/yrangemask002.rar yrangemask002.rar] | ||
| + | |||
|} | |} | ||
<br> | <br> | ||
Revision as of 01:16, 3 June 2020
| 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 reimplementation 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 ←
