colour.LUTSequence#

class colour.LUTSequence(*args: ProtocolLUTSequenceItem)[source]#

Bases: MutableSequence

Define the base class for a LUT sequence, i.e. a series of LUTs, LUT operators or objects implementing the colour.hints.ProtocolLUTSequenceItem protocol.

The colour.LUTSequence class can be used to model series of LUTs such as when a shaper LUT is combined with a 3D LUT.

Parameters:

args (ProtocolLUTSequenceItem) – Sequence of objects implementing the colour.hints.ProtocolLUTSequenceItem protocol.

Attributes

Methods

Examples

>>> from colour.io.luts import LUT1D, LUT3x1D, LUT3D
>>> LUT_1 = LUT1D()
>>> LUT_2 = LUT3D(size=3)
>>> LUT_3 = LUT3x1D()
>>> print(LUTSequence(LUT_1, LUT_2, LUT_3))
LUT Sequence
------------

Overview

    LUT1D --> LUT3D --> LUT3x1D

Operations

    LUT1D - Unity 10
    ----------------

    Dimensions : 1
    Domain     : [ 0.  1.]
    Size       : (10,)

    LUT3D - Unity 3
    ---------------

    Dimensions : 3
    Domain     : [[ 0.  0.  0.]
                  [ 1.  1.  1.]]
    Size       : (3, 3, 3, 3)

    LUT3x1D - Unity 10
    ------------------

    Dimensions : 2
    Domain     : [[ 0.  0.  0.]
                  [ 1.  1.  1.]]
    Size       : (10, 3)
__init__(*args: ProtocolLUTSequenceItem) None[source]#
Parameters:

args (ProtocolLUTSequenceItem) –

Return type:

None

property sequence: List[ProtocolLUTSequenceItem]#

Getter and setter property for the underlying LUT sequence.

Parameters:

value – Value to set the underlying LUT sequence with.

Returns:

Underlying LUT sequence.

Return type:

list

__getitem__(index: int | slice) Any[source]#

Return the LUT sequence item(s) at given index (or slice).

Parameters:

index (int | slice) – Index (or slice) to return the LUT sequence item(s) at.

Returns:

LUT sequence item(s) at given index (or slice).

Return type:

ProtocolLUTSequenceItem

__setitem__(index: int | slice, value: Any)[source]#

Set the LUT sequence at given index (or slice) with given value.

Parameters:
  • index (int | slice) – Index (or slice) to set the LUT sequence value at.

  • value (Any) – Value to set the LUT sequence with.

__delitem__(index: int | slice)[source]#

Delete the LUT sequence item(s) at given index (or slice).

Parameters:

index (int | slice) – Index (or slice) to delete the LUT sequence items at.

__len__() int[source]#

Return the LUT sequence items count.

Returns:

LUT sequence items count.

Return type:

int

__str__() str[source]#

Return a formatted string representation of the LUT sequence.

Returns:

Formatted string representation.

Return type:

str

__repr__() str[source]#

Return an evaluable string representation of the LUT sequence.

Returns:

Evaluable string representation.

Return type:

str

__eq__(other) bool[source]#

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

Parameters:

other – Object to test whether it is equal to the LUT sequence.

Returns:

Whether given object is equal to the LUT sequence.

Return type:

bool

__ne__(other) bool[source]#

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

Parameters:

other – Object to test whether it is not equal to the LUT sequence.

Returns:

Whether given object is not equal to the LUT sequence.

Return type:

bool

insert(index: int, value: ProtocolLUTSequenceItem)[source]#

Insert given LUT at given index into the LUT sequence.

Parameters:
  • index (int) – Index to insert the item at into the LUT sequence.

  • value (ProtocolLUTSequenceItem) – LUT to insert into the LUT sequence.

__hash__ = None#
__weakref__#

list of weak references to the object (if defined)

apply(RGB: ArrayLike, **kwargs: Any) NDArrayFloat[source]#

Apply the LUT sequence sequentially to given RGB colourspace array.

Parameters:
  • RGB (ArrayLike) – RGB colourspace array to apply the LUT sequence sequentially onto.

  • kwargs (Any) – Keywords arguments, the keys must be the class type names for which they are intended to be used with. There is no implemented way to discriminate which class instance the keyword arguments should be used with, thus if many class instances of the same type are members of the sequence, any matching keyword arguments will be used with all the class instances.

Returns:

Processed RGB colourspace array.

Return type:

numpy.ndarray

Examples

>>> import numpy as np
>>> from colour.io.luts import LUT1D, LUT3x1D, LUT3D
>>> from colour.utilities import tstack
>>> LUT_1 = LUT1D(LUT1D.linear_table(16) + 0.125)
>>> LUT_2 = LUT3D(LUT3D.linear_table(16) ** (1 / 2.2))
>>> LUT_3 = LUT3x1D(LUT3x1D.linear_table(16) * 0.750)
>>> LUT_sequence = LUTSequence(LUT_1, LUT_2, LUT_3)
>>> samples = np.linspace(0, 1, 5)
>>> RGB = tstack([samples, samples, samples])
>>> LUT_sequence.apply(RGB, LUT1D={"direction": "Inverse"})
... 
array([[ 0.       ...,  0.       ...,  0.       ...],
       [ 0.2899886...,  0.2899886...,  0.2899886...],
       [ 0.4797662...,  0.4797662...,  0.4797662...],
       [ 0.6055328...,  0.6055328...,  0.6055328...],
       [ 0.7057779...,  0.7057779...,  0.7057779...]])
copy() LUTSequence[source]#

Return a copy of the LUT sequence.

Returns:

LUT sequence copy.

Return type:

colour.LUTSequence