This documentation is for the old version. Go to the latest Graphics Mill docs

Lut.BuildLinear Method

Builds a LUT from linear function with given parameters.

Namespace: Aurigma.GraphicsMill.Transforms
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Sub BuildLinear ( _
	a As Single, _
	b As Single, _
	extended As Boolean _
)
C#
public void BuildLinear(
	float a,
	float b,
	bool extended
)

Parameters

a

Type: System.Single

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

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

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) method.

See Also

Reference