# colour.LUTOperatorMatrix#

class colour.LUTOperatorMatrix(matrix: ArrayLike | None = None, offset: ArrayLike | None = None, *args: Any, **kwargs: Any)[source]#

Define the LUT operator supporting a 3x3 or 4x4 matrix and an offset vector.

Parameters:
• matrix (ArrayLike | None) – 3x3 or 4x4 matrix for the operator.

• offset (ArrayLike | None) – Offset for the operator.

• nameLUT operator name.

• args (Any) –

• kwargs (Any) –

Attributes

Methods

Notes

• The internal `colour.io.Matrix.matrix` and `colour.io.Matrix.offset` properties are reshaped to (4, 4) and (4, ) respectively.

Examples

Instantiating an identity matrix:

```>>> print(LUTOperatorMatrix(name="Identity"))
LUTOperatorMatrix - Identity
----------------------------

Matrix     : [[ 1.  0.  0.  0.]
[ 0.  1.  0.  0.]
[ 0.  0.  1.  0.]
[ 0.  0.  0.  1.]]
Offset     : [ 0.  0.  0.  0.]
```

```>>> matrix = np.array(
...     [
...         [1.45143932, -0.23651075, -0.21492857],
...         [-0.07655377, 1.1762297, -0.09967593],
...         [0.00831615, -0.00603245, 0.9977163],
...     ]
... )
>>> print(
...     LUTOperatorMatrix(
...         matrix,
...         name="AP0 to AP1",
...         comments=["A first comment.", "A second comment."],
...     )
... )
LUTOperatorMatrix - AP0 to AP1
------------------------------

Matrix     : [[ 1.45143932 -0.23651075 -0.21492857  0.        ]
[-0.07655377  1.1762297  -0.09967593  0.        ]
[ 0.00831615 -0.00603245  0.9977163   0.        ]
[ 0.          0.          0.          1.        ]]
Offset     : [ 0.  0.  0.  0.]

A first comment.
A second comment.
```
__init__(matrix: ArrayLike | None = None, offset: ArrayLike | None = None, *args: Any, **kwargs: Any) None[source]#
Parameters:
• matrix (ArrayLike | None) –

• offset (ArrayLike | None) –

• args (Any) –

• kwargs (Any) –

Return type:

None

__hash__ = None#
property matrix: NDArrayFloat#

Getter and setter property for the LUT operator matrix.

Parameters:

value – Value to set the LUT operator matrix with.

Returns:

Operator matrix.

Return type:

`numpy.ndarray`

property offset: NDArrayFloat#

Getter and setter property for the LUT operator offset.

Parameters:

value – Value to set the LUT operator offset with.

Returns:

Operator offset.

Return type:

`numpy.ndarray`

__str__() str[source]#

Return a formatted string representation of the LUT operator.

Returns:

Formatted string representation.

Return type:

`str`

Examples

```>>> print(LUTOperatorMatrix())
LUTOperatorMatrix - LUT Sequence Operator ...
------------------------------------------...

Matrix     : [[ 1.  0.  0.  0.]
[ 0.  1.  0.  0.]
[ 0.  0.  1.  0.]
[ 0.  0.  0.  1.]]
Offset     : [ 0.  0.  0.  0.]
```
__repr__() str[source]#

Return an evaluable string representation of the LUT operator.

Returns:

Evaluable string representation.

Return type:

`str`

Examples

```>>> LUTOperatorMatrix(comments=["A first comment.", "A second comment."])
...
LUTOperatorMatrix([[ 1.,  0.,  0.,  0.],
[ 0.,  1.,  0.,  0.],
[ 0.,  0.,  1.,  0.],
[ 0.,  0.,  0.,  1.]],
[ 0.,  0.,  0.,  0.],
name='LUT Sequence Operator ...',
comments=['A first comment.', 'A second comment.'])
```
__eq__(other: Any) bool[source]#

Return whether the LUT operator is equal to given other object.

Parameters:

other (Any) – Object to test whether it is equal to the LUT operator.

Returns:

Whether given object equal to the LUT operator.

Return type:

`bool`

Examples

```>>> LUTOperatorMatrix() == LUTOperatorMatrix()
True
```
__ne__(other: Any) bool[source]#

Return whether the LUT operator is not equal to given other object.

Parameters:

other (Any) – Object to test whether it is not equal to the LUT operator.

Returns:

Whether given object is not equal to the LUT operator.

Return type:

`bool`

Examples

```>>> LUTOperatorMatrix() != LUTOperatorMatrix(
...     np.reshape(np.linspace(0, 1, 16), (4, 4))
... )
True
```
apply(RGB: ArrayLike, *args: Any, **kwargs: Any) NDArrayFloat[source]#

Apply the LUT operator to given RGB array.

Parameters:
• RGB (ArrayLike) – RGB array to apply the LUT operator transform to.

• apply_offset_first – Whether to apply the offset first and then the matrix.

• args (Any) –

• kwargs (Any) –

Returns:

Transformed RGB array.

Return type:

`numpy.ndarray`

Examples

```>>> matrix = np.array(
...     [
...         [1.45143932, -0.23651075, -0.21492857],
...         [-0.07655377, 1.1762297, -0.09967593],
...         [0.00831615, -0.00603245, 0.9977163],
...     ]
... )
>>> M = LUTOperatorMatrix(matrix)
>>> RGB = np.array([0.3, 0.4, 0.5])
>>> M.apply(RGB)
array([ 0.2333632...,  0.3976877...,  0.4989400...])
```