colour.LUTSequence#

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

Bases: MutableSequence

Define the base class for a LUT sequence.

A LUT sequence represents 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 for the underlying LUT sequence.

Access and modify the sequence of lookup table operations that define the transformation pipeline.

Parameters:

value – Value to set the underlying LUT sequence with.

Returns:

Underlying LUT sequence.

Return type:

list

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

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

Parameters:

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

Returns:

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

Return type:

ProtocolLUTSequenceItem

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

Set the LUT sequence at the specified index or slice with the specified value.

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

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

Return type:

None

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

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

Parameters:

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

Return type:

None

__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.

Generate a string representation that can be evaluated to recreate the LUT sequence with its current state.

Returns:

Evaluable string representation.

Return type:

str

__hash__ = None#
__eq__(other: object) bool[source]#

Test whether the LUT sequence is equal to the specified other object.

Compare this LUT sequence with another object for equality. The comparison evaluates structural and content equivalence.

Parameters:

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

Returns:

Whether specified object is equal to the LUT sequence.

Return type:

bool

__ne__(other: object) bool[source]#

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

Parameters:

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

Returns:

Whether the specified object is not equal to the LUT sequence.

Return type:

bool

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

Insert the specified LUT at the specified index in the LUT sequence.

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

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

Return type:

None

__weakref__#

list of weak references to the object

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

Apply the LUT sequence sequentially to the specified 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