7.2. How to create a discrete LUT and apply it to a ChannelΒΆ

In this example, we will apply a Lookup Table to a Channel called channel to a scene:

import numpy as np
from ORSServiceClass.ORSWidget.orslutwidget.orslutlogic import OrsLUTLogic

lutName = 'a LUT Name'
aLUT = OrsLUTLogic.createLUT(lutName)
aLUT.setIsDiscrete(True)
aLUT.setTableSize(channel.getMaximumValue())
for i in range(np.int(channel.getMaximumValue() + 1)):
    r, g, b = np.random.rand(3)
    color = Color(r, g, b, 1.0)
    aLUT.setColorAtIndex(i, color)

lutUUID = OrsLUTLogic.getLUTUUID(aLUT)

Then use the snippet of How to apply a LUT to a Channel to apply this LUT to a channel.