LUT is short for "lookup table", which is basically an indexed list of numbers. For Basler cameras, you can create a user-defined "luminance lookup table" to replace the pixel values, i.e., the luminance or gray values, in your images.
In the lookup table you can define replacement values for individual pixel values. For example, you can replace a gray value of 4 095 (= maximum gray value for 12-bit pixel formats) by a gray value of 0 (= minimum gray value). This changes all completely white pixels in your images to completely black pixels.
Setting up a user-defined LUT can be useful, e.g., if you want to optimize the luminance of your images. By defining the replacement values in advance and storing them in the camera, you avoid time-consuming calculations by your application. Instead, the camera can simply look up the desired new value in the LUT based on the pixel's initial value.
Info
The value range of the user-defined LUT (0–1 024 or 0–4 096) is not dependent on the currently selected pixel format. It is dependent on the maximum pixel bit depth of the camera.
If your camera supports 12-bit pixel formats, but currently uses an 8-bit pixel format, you will still be able to enter pixel values between 0 and 4 096. The camera uses these values for conversion. Then, it drops the 4 least significant bits of the converted values and transmits the 8 most significant bits.
On most Basler cameras, the user-defined LUT can store up to 512 entries. This size is not sufficient for storing the 1 024 or 4 096 replacement values.
Therefore, the following limitations apply:
On cameras with a maximum pixel bit depth of 10 bit, you can only set the LUTIndex parameter to multiples of two (0, 2, 4, 6, …, 1022). This means that only pixel values of 0, 2, 4, 6, and so on, can be replaced.
On cameras with a maximum pixel bit depth of 12 bit, you can only set the LUTIndex parameter to multiples of eight (0, 8, 16, 24, …, 4088). This means that only pixel values of 0, 8, 16, 24, and so on, can be replaced.
To determine the remaining pixel values, the camera performs a straight line interpolation.
Example: Assume that the camera has a maximum pixel bit depth of 12 bit. Also assume that you have created a LUT that converts a gray value of 24 to a gray value of 20 and a gray value of 32 to a value of 30. In this case, the camera determines the pixel values between 24 and 32 as follows:
Original Pixel Value
Value Stored in LUT
Interpolated Value
New Pixel Value (Rounded)
24
20
20
20
25
-
21.25
21
26
-
22.5
22
27
-
23.75
23
28
-
25
25
29
-
26.25
26
30
-
27.5
27
31
-
28.75
28
32
30
30
30
Info
Pixel values above 4088 are not interpolated. Instead, all pixel values between 4 088 and 4 095 are replaced by the pixel value entered at LUT index position 4 088.
On some Basler cameras, the user-defined LUT can store entries for all replacement values. Dependent on the maximum pixel bit depth of the camera, 1 024 or 4 096 entries are available.
This means that the limitations described in the section above don't apply: You can set the LUTIndex parameter in increments of 1, and no interpolation is performed.
You can replace all entries in the lookup table with a single operation. In many cases, this is faster than repeatedly changing individual entries in the LUT.
To replace all entries in the lookup table:
Set the LUTValueAll parameter to the desired value. Make sure to apply the correct endianness of the 4-byte words (LUT values).
Set the LUTEnable parameter to true.
Info
The LUTValueAll parameter is only available via the pylon API, not via the pylon Viewer feature tree.
On cameras with a maximum pixel bit depth of 12 bit, the LUTValueAll parameter is an array that consists of 4096 x 4 bytes. Each 4-byte word represents a LUTValue parameter value.
The LUTValue parameter values are sorted by the LUTIndex number in ascending order (0 through 4095).
Info
The endianness of the 4-byte words (lut values) depends on your camera model.
If the LUT is limited to 512 entries, only every eighth 4-byte word (0, 8, 16, 24, …, 4088) is actually used by the camera. The other 4-byte words are ignored. Example:
On cameras with a maximum pixel bit depth of 10 bit, the LUTValueAll parameter is an array that consists of 1024 x 4 bytes. Each 4-byte word represents a LUTValue parameter value.
The LUTValue parameter values are sorted by the LUTIndex number in ascending order (0 through 1023).
Info
The endianness of the 4-byte words (lut values) depends on your camera model.
If the LUT is limited to 512 entries, only every second 4-byte word (0, 2, 4, 6, …, 1022) is actually used by the camera. The other 4-byte words are ignored. Example:
// ** Replacing individual LUT entries **// The following lookup table causes an inversion of the pixel values// (bright -> dark, dark -> bright)// Only applies to cameras with a maximum pixel bit depth of 12 bitfor(inti=0;i<4096;i+=8){camera.LUTIndex.SetValue(i);camera.LUTValue.SetValue(4095-i);}// Enable the LUTcamera.LUTEnable.SetValue(true);// ** Replacing all LUT entries in a single operation **// The following lookup table inverts the pixel values// (bright -> dark, dark -> bright)// Only applies to cameras with a maximum pixel bit depth of 12 bit// Note: This is a simplified code sample.// You should always check the camera interface and// the endianness of your system before using LUTValueAll.// For more information, see the 'LUTValueAll' code sample// in the pylon API Documentation.uint32_tlutValues[4096];for(inti=0;i<4096;i+=8){lutValues[i]=4095-i;}camera.LUTValueAll.SetValue(lutValues);// Enable the LUTcamera.LUTEnable.SetValue(true);
This sample code is only available in C++ language.