Pillow LUT tools¶
This package contains tools for loading, manipulating, and generating three-dimensional lookup tables and is designed for Pillow library.
Lookup tables are the powerful instrument for image color transformations and used in many graphics and video editors.
-
pillow_lut.
load_cube_file
(lines, target_mode=None, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Loads 3D lookup table from .cube file format.
Parameters: - lines – Filename or iterable list of strings with file content.
- target_mode – Image mode which should be after color transformation. The default is None, which means mode doesn’t change.
- cls – A class which handles the parsed file.
Default is
ImageFilter.Color3DLUT
.
-
pillow_lut.
load_hald_image
(image, target_mode=None, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Loads 3D lookup table from Hald image (normally .png or .tiff files).
Parameters: - image – Pillow RGB image or path to the file.
- target_mode – Image mode which should be after color transformation. The default is None, which means mode doesn’t change.
- cls – A class which handles the parsed file.
Default is
ImageFilter.Color3DLUT
.
-
pillow_lut.
identity_table
(size, target_mode=None, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Returns noop lookup table with linear distributed values.
Parameters: - size – Size of the table. From 2 to 65.
- target_mode – A mode for the result image. Should have not less
than
channels
channels. Default isNone
, which means that mode wouldn’t be changed.
-
pillow_lut.
rgb_color_enhance
(source, brightness=0, exposure=0, contrast=0, warmth=0, saturation=0, vibrance=0, hue=0, gamma=1.0, linear=False, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Generates 3D color lookup table based on given values of basic color settings.
Parameters: - source – Could be the source lookup table which will be modified, or just a size of new identity table, from 2 to 65. Performance can dramatically decrease wth bigger sizes.
- brightness – One value for all channels, or tuple of three values
from -1.0 to 1.0. Use
exposure
for better result. - exposure – One value for all channels, or tuple of three values from -5.0 to 5.0.
- contrast – One value for all channels, or tuple of three values from -1.0 to 5.0.
- warmth – One value from -1.0 to 1.0.
- saturation – One value for all channels, or tuple of three values from -1.0 to 5.0.
- vibrance – One value for all channels, or tuple of three values from -1.0 to 5.0.
- hue – One value from 0 to 1.0.
- gamma – One value from 0 to 10.0. Default is 1.0.
- linear – boolean value. Convert values from sRGB to linear color space before the manipulating and return after. Default is False. Most arguments more sensitive in this mode.
-
pillow_lut.
sample_lut_linear
(lut, point)¶ Computes the new point value from given 3D lookup table using linear interpolation.
Parameters: - lut – Lookup table,
ImageFilter.Color3DLUT
object. - point – A tuple of 3 values with coordinates in the cube, normalized from 0.0 to 1.0. Could be out of range.
- lut – Lookup table,
-
pillow_lut.
sample_lut_cubic
(lut, point)¶ Computes the new point value from given 3D lookup table using cubic interpolation.
Parameters: - lut – Lookup table,
ImageFilter.Color3DLUT
object. - point – A tuple of 3 values with coordinates in the cube, normalized from 0.0 to 1.0. Could be out of range, in this case, will be linear interpolated using two extreme values.
- lut – Lookup table,
-
pillow_lut.
resize_lut
(source, target_size, interp=2, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Resizes given lookup table to new size using interpolation.
Parameters: - source – Source lookup table,
ImageFilter.Color3DLUT
object. - target_size – Size of the resulting lookup table.
- interp – Interpolation type,
Image.LINEAR
orImage.CUBIC
. Linear is default. Cubic is dramatically slower.
- source – Source lookup table,
-
pillow_lut.
transform_lut
(source, lut, target_size=None, interp=2, cls=<class 'PIL.ImageFilter.Color3DLUT'>)¶ Transforms given lookup table using another table and returns the result. Sizes of the tables do not have to be the same. Moreover, you can set the result table size with
target_size
argument.Parameters: - source – Source lookup table,
ImageFilter.Color3DLUT
object. - lut – Applied lookup table,
ImageFilter.Color3DLUT
object. - target_size – Optional size of the resulting lookup table.
By default, size of the
source
will be used. - interp – Interpolation type,
Image.LINEAR
orImage.CUBIC
. Linear is default. Cubic is dramatically slower.
- source – Source lookup table,
-
pillow_lut.
amplify_lut
(source, scale)¶ Amplifies given lookup table compared to identity table the same size. For 4-channel lookup tables the fourth channel will be unschanged.
Parameters: - source – Source lookup table,
ImageFilter.Color3DLUT
object. - scale – One or three floats which define the amplification strength. 1.0 mean no changes, 0.0 transforms to identity table.
- source – Source lookup table,