colour.LUTOperatorMatrix¶
- class colour.LUTOperatorMatrix(matrix: Optional[ArrayLike] = None, offset: Optional[ArrayLike] = None, *args: Any, **kwargs: Any)[source]¶
Bases:
colour.io.luts.operator.AbstractLUTSequenceOperator
Define the LUT operator supporting a 3x3 or 4x4 matrix and an offset vector.
- Parameters
matrix (Optional[ArrayLike]) – 3x3 or 4x4 matrix for the operator.
offset (Optional[ArrayLike]) – Offset for the operator.
name – LUT operator name.
comments – Comments to add to the LUT operator.
args (Any) –
kwargs (Any) –
Attributes
Methods
Notes
The internal
colour.io.Matrix.matrix
andcolour.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.]
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: Optional[ArrayLike] = None, offset: Optional[ArrayLike] = None, *args: Any, **kwargs: Any)[source]¶
- Parameters
matrix (Optional[ArrayLike]) –
offset (Optional[ArrayLike]) –
args (Any) –
kwargs (Any) –
- __hash__ = None¶
- property matrix: numpy.ndarray¶
Getter and setter property for the LUT operator matrix.
- Parameters
value – Value to set the LUT operator matrix with.
- Returns
Operator matrix.
- Return type
- property offset: numpy.ndarray¶
Getter and setter property for the LUT operator offset.
- Parameters
value – Value to set the LUT operator offset with.
- Returns
Operator offset.
- 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.'])
- __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
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
Examples
>>> LUTOperatorMatrix() != LUTOperatorMatrix( ... np.linspace(0, 1, 16).reshape([4, 4])) True
- apply(RGB: ArrayLike, *args: Any, **kwargs: Any) numpy.ndarray [source]¶
Apply the LUT operator to given 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...])