YRangeMask

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(YRangeMask)
 
m (Description)
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
{{FilterCat4|External_filters|Plugins|Adjustment_filters|Masking}}
+
{{FilterCat4|External_filters|Scripts|Adjustment_filters|Masking}}
 
{{Filter3
 
{{Filter3
| {{Author/putin}}
+
| {{Author/Chikuzen}}
| v0.03
+
| 2016/01/24
|[http://putin999.web.fc2.com/yrangemask003.rar yrangemask003.rar]
+
|[[YRangeMask#Script|mt_yrangemask.avsi]]
 
| Masking
 
| Masking
| Closed source
+
|  
 
|}}
 
|}}
 
 
== Description ==
 
== Description ==
AviSynth plug-in to create a mask by specifying the range of the brightness.
+
AviSynth script to create a mask by specifying the range of the brightness.<br>
 +
<code>mt_yrangemask</code> is a script implementation of the old YRangeMask plugin by Putin. The script version is much faster and supports additional colorspaces.
 
<br>
 
<br>
 
<br>
 
<br>
  
 
== Requirements ==
 
== Requirements ==
* AviSynth 2.5.8 or [http://sourceforge.net/projects/avisynth2/ greater]
+
* [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]]
* [http://www.microsoft.com/en-us/download/details.aspx?id=26999 Microsoft Visual C++ 2010 Redistributable Package (<tt>vcredist_x86.exe</tt>)]
+
<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|YRangeMask (clip , int "min_y", int "fade_min_y", int "max_y", int "fade_max_y", bool "invert")}}
+
:{{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 44:
 
:::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'")
  
== Examples ==  
+
    min = string(min - 1)
#<code>YRangeMask(min_y=16, fade_min_y=0, max_y=80, fade_max_y=0)</code><br>
+
    max = string(max + 1)
#<code>YRangeMask(min_y=16, fade_min_y=4, max_y=80, fade_max_y=16)</code>
+
    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>
 
<br>
 +
== Examples ==
 +
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]]
 +
 +
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        02/06/2012     - ?
+
              2016/01/24      - mt_yrangemask: MaskTools2 script reimplementation by Chikuzen
  v0.02        28/05/2012     - ?
+
  v0.03        2012/06/02     - ?
  v0.01        01/05/2012     - initial release
+
  v0.02        2012/05/28     - ?
 +
  v0.01        2012/05/01     - initial release
 
<br>
 
<br>
 
== Archived Downloads ==
 
== Archived Downloads ==
{| class="wikitable" border="1"; width="600px"
+
*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
!!width="150px"| Mirror
 
 
|-
 
|-
 
!v0.03
 
!v0.03
|[http://putin999.web.fc2.com/yrangemask003.rar yrangemask003.rar]
 
 
|[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://putin999.web.fc2.com/yrangemask002.rar yrangemask002.rar]
 
 
|[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>
 
== External Links ==
 
== External Links ==
 
*[http://potatosub.blog.fc2.com/blog-entry-48.html potatosub's blog] - Using [[WarpSharp]] + YRangeMask (Japanese).
 
*[http://potatosub.blog.fc2.com/blog-entry-48.html potatosub's blog] - Using [[WarpSharp]] + YRangeMask (Japanese).
 +
*[http://csbarn.blogspot.com/2016/01/mtyrangemask.html csbarn.blogspot.com] - mt_yrangemask script, uses MaskTools2 for much better performance (Japanese).
 
<br>
 
<br>
 
<br>
 
<br>
 
-----------------------------------------------
 
-----------------------------------------------
 
'''Back to [[External_filters#Averaging.2FLayering.2FMasking|External Filters]] &larr;'''
 
'''Back to [[External_filters#Averaging.2FLayering.2FMasking|External Filters]] &larr;'''

Latest revision as of 20:02, 25 June 2020

Abstract
Author Chikuzen
Version 2016/01/24
Download mt_yrangemask.avsi
Category Masking
License
Discussion

Contents

[edit] 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.

[edit] Requirements


[edit] Required Plugins

Latest versions of the following filters are recommended unless stated otherwise.


[edit] 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.


int  min_y = 0
Minimum threshold.


int  fade_min_y = 0
How many minimum pixels to fade.


int  max_y = 0
Maximum threshold.


int  fade_max_y = 0
How many maximum pixels to fade.


bool  invert = false
Set to true to invert the mask.


[edit] 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")
}


[edit] 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)

Yrangemask.png

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)


[edit] 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


[edit] 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


[edit] External Links




Back to External Filters

Personal tools