Creates a lookup table to be used with AdjustCurve(FIBITMAP, array<Byte>[]()[], FREE_IMAGE_COLOR_CHANNEL) which may adjusts brightness and contrast, correct gamma and invert the image with a single call to AdjustCurve(FIBITMAP, array<Byte>[]()[], FREE_IMAGE_COLOR_CHANNEL).

Namespace:  FreeImageAPI
Assembly:  FreeImageNET (in FreeImageNET.dll)

Syntax

C#
public static int GetAdjustColorsLookupTable(
	byte[] LUT,
	double brightness,
	double contrast,
	double gamma,
	bool invert
)
Visual Basic (Declaration)
Public Shared Function GetAdjustColorsLookupTable ( _
	LUT As Byte(), _
	brightness As Double, _
	contrast As Double, _
	gamma As Double, _
	invert As Boolean _
) As Integer
Visual C++
public:
static int GetAdjustColorsLookupTable(
	array<unsigned char>^ LUT, 
	double brightness, 
	double contrast, 
	double gamma, 
	bool invert
)

Parameters

LUT
Type: array< System..::.Byte >[]()[]
brightness
Type: System..::.Double
Percentage brightness value where -100 <= brightness <= 100.

A value of 0 means no change, less than 0 will make the image darker and greater than 0 will make the image brighter.

contrast
Type: System..::.Double
Percentage contrast value where -100 <= contrast <= 100.

A value of 0 means no change, less than 0 will decrease the contrast and greater than 0 will increase the contrast of the image.

gamma
Type: System..::.Double
Gamma value to be used for gamma correction.

A value of 1.0 leaves the image alone, less than one darkens it, and greater than one lightens it.

invert
Type: System..::.Boolean
If set to true, the image will be inverted.

Return Value

The number of adjustments applied to the resulting lookup table compared to a blind lookup table.

Remarks

This function creates a lookup table to be used with AdjustCurve(FIBITMAP, array<Byte>[]()[], FREE_IMAGE_COLOR_CHANNEL) which may adjust brightness and contrast, correct gamma and invert the image with a single call to AdjustCurve(FIBITMAP, array<Byte>[]()[], FREE_IMAGE_COLOR_CHANNEL). If more than one of these image display properties need to be adjusted, using a combined lookup table should be preferred over calling each adjustment function separately. That's particularly true for huge images or if performance is an issue. Then, the expensive process of iterating over all pixels of an image is performed only once and not up to four times.

Furthermore, the lookup table created does not depend on the order, in which each single adjustment operation is performed. Due to rounding and byte casting issues, it actually matters in which order individual adjustment operations are performed. Both of the following snippets most likely produce different results:

CopyC#
// snippet 1: contrast, brightness
AdjustContrast(dib, 15.0);
AdjustBrightness(dib, 50.0);

CopyC#
// snippet 2: brightness, contrast
AdjustBrightness(dib, 50.0);
AdjustContrast(dib, 15.0);

Better and even faster would be snippet 3:

CopyC#
// snippet 3:
byte[] lut = new byte[256];
GetAdjustColorsLookupTable(lut, 50.0, 15.0, 1.0, false);
AdjustCurve(dib, lut, FREE_IMAGE_COLOR_CHANNEL.FICC_RGB);

This function is also used internally by AdjustColors(FIBITMAP, Double, Double, Double, Boolean), which does not return the lookup table, but uses it to call AdjustCurve(FIBITMAP, array<Byte>[]()[], FREE_IMAGE_COLOR_CHANNEL) on the passed image.

Version Information

FreeImage.NET

Supported in: 3.11.0, 3.12.0, 3.13.0, 3.13.1

See Also