MaskTools2/mt lutspa

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(mt_lutspa)
 
(Examples: change the order of gradients and add sources for examples)
 
(2 intermediate revisions by one user not shown)
Line 53: Line 53:
 
<br>
 
<br>
 
== Examples ==
 
== Examples ==
'''TO DO!'''
+
For the following examples lets assume our input clip is: <code>[[BlankClip|BlankClip(width=128, height=128, pixel_type="Y8")]]</code>
 +
 
 +
:{| class="wikitable" border="1"; width="100%"
 +
|-
 +
!!width="50%"| Lines and Patterns
 +
!!width="50%"| Gradients
 +
|-
 +
|
 +
*<code>mt_lutspa(mode="absolute", expr="x 32 % 16 < 0 255 ?")</code>
 +
:[[File:mt_lutspa_vlines1.png]]
 +
|
 +
*<code>mt_lutspa(mode="relative", expr="x 255 *")</code>
 +
[[File:mt_lutspa_gradient4.png]]
 +
|-
 +
|
 +
*<code>mt_lutspa(mode="relative", expr="y 32 480 / - 82 480 / / pi * sin 128 * 128 +")</code>
 +
:[[File:mt_lutspa_hlines1.png]]
 +
|
 +
*<code>mt_lutspa(mode="relative", expr="x y + 256 * 2 /")</code>
 +
[[File:mt_lutspa_gradient2.png]]
 +
|-
 +
|
 +
*<code>mt_lutspa(relative=false, expr="y 5 % 0.01 < 55 y 5 % 1.1 < 200 y 5 % 3.9 > 200 255 ? ? ?")</code>
 +
:[[File:mt_lutspa_hlines2.png‎]]
 +
|
 +
* <code>mt_lutspa(expr="x 2 ^ y 2 ^ + 2 / 0.5 ^ 256 *")</code>
 +
[[File:mt_lutspa_gradient1.png]]
 +
|-
 +
|
 +
*<code>[https://forum.doom9.org/showthread.php?p=1433058#post1433058 mt_lutspa(relative=false, expr="y 6 % 0.01 < 0 255 ?")]</code>
 +
:[[File:mt_lutspa_hlines3.png‎]]
 +
|
 +
*<code>mt_lutspa("absolute", expr="y 800 >= y 1000 <= & 255 y 800 y 1050 < & y 1050 – abs 5.1 * 0 ? ? ?")</code>
 +
[[File:mt_lutspa_gradient3.png]]
 +
|-
 +
|
 +
*<code>mt_lutspa(mode="absolute", expr="x 32 % 16 < 0 1 ? y 32 % 16 < 0 1 ? + 1 == 0 255 ?")</code>
 +
:[[File:mt_lutspa_checkerboard.png‎‎]]
 +
|
 +
*<code>[https://forum.doom9.org/showthread.php?p=1219924#post1219924  mt_lutspa(mode="relative", expr="x 1 2 / - abs y 1 2 / - abs + 256 *")]</code>
 +
[[File:mt_lutspa_gradient5.png]]
 +
|-
 +
|
 +
*<code>mt_lutspa(relative=false, expr="x 16 % 0 == y 16 % 0 == | 255 0 ?")</code>
 +
:[[File:mt_lutspa_grid.png‎]]
 +
|
 +
*<code>[https://web.archive.org/web/20181111105049/https://www.nmm-hd.org/newbbs/viewtopic.php?t=770#p6981 mt_lutspa(mode="relative", expr="x y 1 x - 1 y - * * * 4096 *")]</code>
 +
[[File:mt_lutspa_gradient6.png]]
 +
|}
 
<br>
 
<br>
 
<br>
 
<br>

Latest revision as of 06:33, 22 January 2022

Computes the value of a pixel according to its spatial position.

[edit] Syntax and Parameters

mt_lutspa (clip, string "mode", bool "relative", bool "biased", string "expr", string "yExpr", string "uExpr", string "vExpr", int "Y", int "U", int"V", string "chroma", int "offX", int "offY", int "w" int "h")


clip   =
The clip is used as a template (for the frame count, the width, the height and the colorspace).


string  mode = "relative"
mode controls how the pixels coordinates are transformed into a value. It overrides the legacy parameters, relative and biased.
Possible values for mode are :
  • "absolute" : x and y go from 0 to width - 1 and height - 1. Equivalent to relative = false.
  • "relative", or "relative opened", or "relative exclusive" : x and y go from 0 to 1 (excluded). Equivalent to relative = true, biased = true.
  • "relative closed", or "relative inclusive" : x and y go from 0 to 1 (included). Equivalent to relative = true, biased = false.


bool  relative = true
relative, defaulted to true, indicates whether x & y should be absolute (x ranging from 0 to the clip's width, y from 0 to the height), or relative (x & y ranging from 0 to 1).


bool  biased = true
biased is used only when relative is true, and indicates whether x and y range from 0 to 1 included (biased = false) or excluded (biased = true).


string  expr = "x"
string  yExpr = "x"
string  uExpr = "x"
string  vExpr = "x"
It computes the value of each pixels according to its coordinates and the given lut. Variable x and y in the lut corresponds respectively to absciss and ordinate of the pixel.


int  Y = 3
int  U = 1
int  V = 1
These three values describe the actual processing mode that is to be used on each plane / channel. Here is how the modes are coded :
  • x = -255...0 : all the pixels of the plane will be set to -x.
  • x = 1 : the plane will not be processed. That means the content of the plane after the filter is pure garbage.
  • x = 2 : the plane of the first input clip will be copied.
  • x = 3 : the plane will be processed with the processing the filter is designed to do.


string  chroma = ""
When defined, the value contained in this string will overwrite the U and V processing modes.
This is a nice addition proposed by mg262 that makes the filter more user friendly. Allowed values for chroma are:
  • "process" : set u = v = 3.
  • "copy" or "copy first" : set u = v = 2.
  • "xxx", where xxx is a number : set u = v = -xxx.


int  offX = 0
int  offY = 0
offX and offY are the top left coordinates of the box where the actual processing shall occur. Everything outside that box will be garbage.


int  w = -1
int  h = -1
w and h are the width and height of the processed box. -1 means that the box extends to the lower right corner of the video. That also means that default settings are meant to process the whole picture.


[edit] Examples

For the following examples lets assume our input clip is: BlankClip(width=128, height=128, pixel_type="Y8")

Lines and Patterns Gradients
  • mt_lutspa(mode="absolute", expr="x 32 % 16 < 0 255 ?")
Mt lutspa vlines1.png
  • mt_lutspa(mode="relative", expr="x 255 *")

Mt lutspa gradient4.png

  • mt_lutspa(mode="relative", expr="y 32 480 / - 82 480 / / pi * sin 128 * 128 +")
Mt lutspa hlines1.png
  • mt_lutspa(mode="relative", expr="x y + 256 * 2 /")

Mt lutspa gradient2.png

  • mt_lutspa(relative=false, expr="y 5 % 0.01 < 55 y 5 % 1.1 < 200 y 5 % 3.9 > 200 255 ? ? ?")
Mt lutspa hlines2.png
  • mt_lutspa(expr="x 2 ^ y 2 ^ + 2 / 0.5 ^ 256 *")

Mt lutspa gradient1.png

Mt lutspa hlines3.png
  • mt_lutspa("absolute", expr="y 800 >= y 1000 <= & 255 y 800 y 1050 < & y 1050 – abs 5.1 * 0 ? ? ?")

Mt lutspa gradient3.png

  • mt_lutspa(mode="absolute", expr="x 32 % 16 < 0 1 ? y 32 % 16 < 0 1 ? + 1 == 0 255 ?")
Mt lutspa checkerboard.png

Mt lutspa gradient5.png

  • mt_lutspa(relative=false, expr="x 16 % 0 == y 16 % 0 == | 255 0 ?")
Mt lutspa grid.png

Mt lutspa gradient6.png




Back to MaskTools2


Personal tools