---
title: "Lut Class"
canonical: https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Transforms_Lut.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# Lut Class
 
This class represents look-up table (LUT) used for tone correction.
 
**Namespace:** [Aurigma.GraphicsMill.Transforms](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Transforms.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
<DefaultMemberAttribute("Item")> _
Public NotInheritable Class Lut _Inherits LockableObject _Implements ICloneable, IEnumerable
```
 
```csharp
[DefaultMemberAttribute("Item")]
public sealed class Lut : LockableObject, ICloneable, IEnumerable
```
 
## Remarks
  
Look-up tables are used in most tone correction algorithms. LUT defines a "luminosity function", in other words, a rule which translate channel luminosity to another value. Actually it is implemented as an array where entries means the luminosity values for channels which has luminosity equal to this entry index. To make it more clean, let's see the pseudocode for the algorithm which uses LUT:
 
```
' This is a pseudocode demonstrating 
' how LUT works. Note, it is not an actual code and 
' this syntax is not correct for Graphics Mill objects! It
' is just used for brevity.

' Let's assume that width and height - image dimension (both for input 
' and output), channelCount - number of channels defined for bitmap pixel format
' (also the same in both bitmaps). LUT is specified look-up table

For i = 0 To height - 1For j = 0 To width - 1	For k = 0 to channelCount - 1		outputBitmap(i, j, k) = LUT(inputBitmap(i, j, k))	NextNext
Next
```
 
```csharp
// This is a pseudocode demonstrating 
// how LUT works. Note, it is not an actual code and 
// this syntax is not correct for Graphics Mill objects! It
// is just used for brevity.

// Let's assume that width and height - image dimension (both for input 
// and output), channelCount - number of channels defined for bitmap pixel format
// (also the same in both bitmaps). LUT is specified look-up table

for ( i = 0; i &lt; height - 1; i++)
{for ( j = 0; j &lt; width - 1; j++){	for ( k = 0; k &lt; channelCount - 1; k++)	{		outputBitmap[i, j, k] = LUT[inputBitmap[i, j, k]];	}}
}
```
 
For LUT entries the following rules are true:
 
1. Minimum value of the LUT entry is 0.
2. Maximum value of the LUT entry is a maximum possible luminosity for target pixel format. If pixel format is not extended (i. e. it has 8 bits per channel), maximum value is 255. For extended pixel formats (16 bits per channel) maximum value is 65535.
3. LUT has as much entries as maximum possible luminosity (for 8 bit per channel images it is 255, for 16 bits per channel images - 65535).
4. If LUT is not define monotone increasing function, some pixel values will be inverted (at the decreasing function sections).

As LUT values depend on the target bitmap pixel format (saying more precisely, it depends on the channel bit depth), this class provides a property [IsExtended](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_Lut_IsExtended.htm.md). When you change it, the look-up table is resized either to 8-bit or 16-bit case. Besides of that each contrustor (instead of parameterless one) has argument specifying what bit depth to use.
 
**Note** 
If you create 16-bit LUT, then set [IsExtended](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_Lut_IsExtended.htm.md) property to **false** (convert it to 8-bit), and after that set it back to **true**, LUT won't be the same as initially. Some information can be lost. It interpolates the missing entries linearly.
 
You can fill the LUT as if it is common array using property [Item\[Int32\]](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_Lut_Item_1_e1836fc4.htm.md). To check how much entries it actually has, use [Length](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Transforms_Lut_Length.htm.md) property. You can also create predefined LUTs using **BuildXXX** methods. For example, [BuildEmpty(Boolean)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Transforms_Lut_BuildEmpty_1_ea7b1ae4.htm.md) method creates LUT filled with zeros. [BuildFromSpline(PointF\[\], Boolean)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Transforms_Lut_BuildFromSpline_2_77a5e52f.htm.md) method defines a LUT as a curve which passes specified array of points. [BuildLinear(Single, Single, Boolean)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Transforms_Lut_BuildLinear_3_0ac4a004.htm.md) method defines a LUT as a linear function with given parameters.
 
## Inheritance Hierarchy
  
- [System.Object](http://msdn2.microsoft.com/en-us/e5kfa45b)
    - [Aurigma.GraphicsMill.LockableObject](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_LockableObject.htm.md)
        - Aurigma.GraphicsMill.Transforms.Lut
 
## Thread Safety
 Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
   
## See Also

### Reference

- [Lut Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_Transforms_Lut.htm.md)
- [Aurigma.GraphicsMill.Transforms Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Transforms.htm.md)
