---
title: "Lut..::.BuildLinear Method "
canonical: https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Transforms_Lut_BuildLinear_3_0ac4a004.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.BuildLinear Method 
 
Builds a LUT from linear function with given parameters.
 
**Namespace:** [Aurigma.GraphicsMill.Transforms](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Transforms.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public Sub BuildLinear ( _a As Single, _b As Single, _extended As Boolean _
)
```
 
```csharp
public void BuildLinear(float a,float b,bool extended
)
```
 
### Parameters
 
 - a
     - Type: [System.Single](http://msdn2.microsoft.com/en-us/3www918f)
Value that specifies *a* parameter of the linear function (an angle of the line slope). See **Remarks** section for more details.

 - b
     - Type: [System.Single](http://msdn2.microsoft.com/en-us/3www918f)
Value that specifies *b* parameter of the linear function (a line shift relatively the origin of coordinates). See **Remarks** section for more details.

 - extended
     - Type: [System.Boolean](http://msdn2.microsoft.com/en-us/a28wyd50)
Value that specifies if LUTshould be build for extended (16 bits per channel) or non-extended (8 bits per channel) bitmaps. If it is **true**, LUT entries number is 65536 and maximum value is 65535, otherwise entries number is 256 and maximum value is 255.
 
## Remarks
  
Linear functions are described with two parameters *a* and *b* in the following way:
 
`f(x) = a * x + b`
 
Argument *a* defines an angle of the line slope (to be more precise, it is a tangent of this angle). When this argument is 0, function degenerates to `f(x) = b`, and the line becomes parallel to the x-axis.
 
Argument *b* defines a shift of the line relatively the origin of coordinates, i. e. point (0, 0). When this argument is 0, function degenerates to `f(x) = a*x`, and the line passes through the origin of coordinates.
 
Quite often you have two points and need to build a line which connects them. Let's assume that these points are specified with coordinates (x1, y1) and (x2, y2) correspondingly. In this case you can calculate parameters *a* and *b* in the following way:
 
```
a = (y1 - y2) / (x1 - x2)
b = (y2 * x1 - y1 * x2) / (x1 - x2)
```
 
Draw attention, x1 and x2 cannot be equal to avoid division by zero. It means that you cannot specify a line which is absolutely parallel to y-axis. As a workaround, you should compare these values before *a* and *b* calculating, and if they are equal, add to one of them small number (e.g. 0.001). As LUT is a discrete function, it will cause no problem.
 
Linear function with *a* = 1 and *b* = 0 produces LUT which does not change an image (in other words, input luminosity values are mapped to the same output values). You can also create such LUT with [BuildIdentical(Boolean)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Transforms_Lut_BuildIdentical_1_ea7b1ae4.htm.md) method.
   
## See Also

### Reference

- [Lut Class](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Transforms_Lut.htm.md)
- [Aurigma.GraphicsMill.Transforms Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Transforms.htm.md)
