class_docstr: Three-dimensional color lookup table.
  
  Transforms 3-channel pixels using the values of the channels as coordinates
  in the 3D lookup table and interpolating the nearest elements.
  
  This method allows you to apply almost any color transformation
  in constant time by using pre-calculated decimated tables.
  
  .. versionadded:: 5.2.0
  
  :param size: Size of the table. One int or tuple of (int, int, int).
               Minimal size in any dimension is 2, maximum is 65.
  :param table: Flat lookup table. A list of ``channels * size**3``
                float elements or a list of ``size**3`` channels-sized
                tuples with floats. Channels are changed first,
                then first dimension, then second, then third.
                Value 0.0 corresponds lowest value of output, 1.0 highest.
  :param channels: Number of channels in the table. Could be 3 or 4.
                   Default is 3.
  :param target_mode: A mode for the result image. Should have not less
                      than ``channels`` channels. Default is ``None``,
                      which means that mode wouldn't be changed.
class_docstr_tok: ["Three-dimensional","color","lookup","table",".","Transforms","3-channel","pixels","using","the","values","of","the","channels","as","coordinates","in","the","3D","lookup","table","and","interpolating","the","nearest","elements",".","This","method","allows","you","to","apply","almost","any","color","transformation","in","constant","time","by","using","pre-calculated","decimated","tables",".","..","versionadded",":",":","5.2.0",":","param","size",":","Size","of","the","table",".","One","int","or","tuple","of","(","int",",","int",",","int",")",".","Minimal","size","in","any","dimension","is","2",",","maximum","is","65.",":","param","table",":","Flat","lookup","table",".","A","list","of","``","channels","*","size","*","*","3","``","float","elements","or","a","list","of","``","size","*","*","3","``","channels-sized","tuples","with","floats",".","Channels","are","changed","first",",","then","first","dimension",",","then","second",",","then","third",".","Value","0.0","corresponds","lowest","value","of","output",",","1.0","highest",".",":","param","channels",":","Number","of","channels","in","the","table",".","Could","be","3","or","4",".","Default","is","3.",":","param","target_mode",":","A","mode","for","the","result","image",".","Should","have","not","less","than","``","channels","``","channels",".","Default","is","``","None","``",",","which","means","that","mode","would","n't","be","changed","."]
code: def __init__(
      self, size, table, channels=3, target_mode=None, **kwargs
  ):
      if channels not in (3, 4):
          raise ValueError("Only 3 or 4 output channels are supported")
      self.size = size = self._check_size(size)
      self.channels = channels
      self.mode = target_mode
  
      # Hidden flag `_copy_table=False` could be used to avoid extra copying
      # of the table if the table is specially made for the constructor.
      copy_table = kwargs.get("_copy_table", True)
      items = size[0] * size[1] * size[2]
      wrong_size = False
  
      numpy = None
      if hasattr(table, "shape"):
          try:
              import numpy
          except ImportError:  # pragma: no cover
              pass
  
      if numpy and isinstance(table, numpy.ndarray):
          if copy_table:
              table = table.copy()
  
          if table.shape in [
              (items * channels,),
              (items, channels),
              (size[2], size[1], size[0], channels),
          ]:
              table = table.reshape(items * channels)
          else:
              wrong_size = True
  
      else:
          if copy_table:
              table = list(table)
  
          # Convert to a flat list
          if table and isinstance(table[0], (list, tuple)):
              table, raw_table = [], table
              for pixel in raw_table:
                  if len(pixel) != channels:
                      raise ValueError(
                          "The elements of the table should "
                          "have a length of {}.".format(channels)
                      )
                  table.extend(pixel)
  
      if wrong_size or len(table) != items * channels:
          raise ValueError(
              "The table should have either channels * size**3 float items "
              "or size**3 items of channels-sized tuples with floats. "
              f"Table should be: {channels}x{size[0]}x{size[1]}x{size[2]}. "
              f"Actual length: {len(table)}"
          )
      self.table = table
  
imports: import functools
label_desc: Use image node_id 1 to create a new Color3DLUT object from inherited base classes: MultibandFilter with example: obj = Color3DLUT(size, table, channels, target_mode)