colour.LUTOperatorMatrix#
- class colour.LUTOperatorMatrix(matrix: ArrayLike | None = None, offset: ArrayLike | None = None, *args: Any, **kwargs: Any)[source]#
Bases:
AbstractLUTSequenceOperatorDefine the LUT operator that applies matrix transformations and offset vectors for colour space conversions.
Support 3x3 or 4x4 matrix operations with optional offset vectors to perform affine transformations on RGB colourspace data. The operator internally reshapes matrices to 4x4 and offsets to 4-element vectors to maintain computational consistency.
- Parameters:
Attributes
Methods
Notes
The internal
colour.io.Matrix.matrixandcolour.io.Matrix.offsetproperties 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.]
Instantiating a matrix with comments:
>>> 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]#
- property matrix: NDArrayFloat#
Getter and setter for the LUT operator matrix.
- Parameters:
value – Value to set the LUT operator matrix with.
- Returns:
Operator matrix.
- Return type:
- property offset: NDArrayFloat#
Getter and setter for the LUT operator offset vector.
The offset vector is applied after the matrix transformation in the LUT operator, enabling translation operations in the colour space.
- Parameters:
value – Value to set the LUT operator offset with.
- Returns:
Operator offset vector.
- Return type:
- __str__() str[source]#
Return a formatted string representation of the LUT operator.
- Returns:
Formatted string representation.
- Return type:
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:
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.'])
- __hash__ = None#
- __eq__(other: object) bool[source]#
Determine whether the LUT operator is equal to the specified other object.
- Parameters:
other (object) – Object to test whether it is equal to the LUT operator.
- Returns:
Whether specified object equal to the LUT operator.
- Return type:
Examples
>>> LUTOperatorMatrix() == LUTOperatorMatrix() True
- __ne__(other: object) bool[source]#
Determine whether the LUT operator is not equal to the specified other object.
- Parameters:
other (object) – Object to test whether it is not equal to the LUT operator.
- Returns:
Whether the specified object is not equal to the LUT operator.
- Return type:
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 the specified RGB array.
- Parameters:
- Returns:
Transformed RGB array.
- Return type:
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...])