# MaskTools/YV12LUT

YV12LUT (clip[, string "yexpr"[, string "uexpr"[, string "vexpr"]]])

YUY2LUT (clip[, string "yexpr"[, string "uexpr"[, string "vexpr"]]])

RGBLUT (clip[, string "Rexpr"[, string "Gexpr"[, string "Bexpr"[, string "AMPFile"]]]])

YV12LUTxy (clipx, clipy[, string "yexpr"[, string "uexpr"[, string "vexpr"]]])

**Plugin**: MaskTools

These filters apply a function to each pixel of the picture. In order to allow a fast computation, every possible value of the function are precomputed and stored in a Look-Up Table (hence the name). That makes the filters fairly fast.

RGBLUT works exactly the same way as YV12LUT, except that it has an additional argument `AMPFile`. It allows you to load a photoshop color profile.

In order to be able to apply almost every possible function, this one is given by a string which represents an expression in reverse polish notation. The principle of this notation is to write first the operands / parameters of an operator / function, and then the operator / function itself. Hence, "3 + 7" becomes "3 7 +", and "sin(3)" becomes "3 sin". Going further in the explanations, "3 * 7 + 5" becomes "3 7 * 5 +", and "(3 + 7) * 5" : "3 7 + 5 *". Now, you understand the main asset of this notation: no need of parenthesis.

Computations are lead on real numbers. Positive numbers also represent a true statement, whereas negative numbers represent a false statement. In the string, the symbol "x" is tha value of the pixel before the use of the function. For YV12LUTxy you also have the symbol "y", which represents the value of the collocated pixel in the second clip. The symbols must be separated by a single space.

Some **operators** and **functions** are implemented :

- +, -, /, *, ^, % are the operators plus, minus, divide, multiply, power and modulo.
- &, |, °, !& are the logical operators and, or, xor, and not. If the result is true, they return 1.0, else -1.0.
- <, <=, >, >=, =, != are the relationnal operators less than, less or equal to, more than, more or equal to, equal to, not equal to. If the result is true, they return 1.0, else -1.0.
- cos, sin, tan, acos, asin, atan, exp, log, abs are the functions cosine, sine, tangent, arccosine, arcsine, arctangent, exponential, napierian logarithm, absolute value.
- ? allows to do a condition test. It's a ternary operator, the first operand being the condition, the second the value if the condition is true, the third if false.

Some **examples**:

- Binarization of the picture with a threshold at 128:

"x 128 < 0 255 ?"

- It is translated as:

"(x < 128) ? 0 : 255"

- Levels(il, gamma, ih, ol, oh) (have a look at the filter Levels):

"x il - ih il - / 1 gamma / ^ oh ol - *"

- It is translated as:

"(((x - il) / (ih - il)) ^ (1 / gamma)) * (oh - ol)"

Defaults are: `Yexpr` = `Uexpr` = `Vexpr` = "x" (hence, the filter does nothing ).

Back to MaskTools.