This is done by creating a user-defined lookup table (LUT).
You can also use the LUT Value All feature to replace all pixel values in a single operation.
In this topic Hide
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.
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.
Basler recommends using a programming loop (e.g., a for-loop) to iterate through the values. See the sample code below.
If you want to replace all pixel values, Basler recommends using the LUT Value All feature because it is quicker than replacing individual pixel values.
The number of entries available in the LUT varies by camera model.
Depending on the number of LUT entries, it is not always possible to store replacement values for all possible pixel values.
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:
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 |
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 do not apply: You can set the LUTIndex parameter in increments of 1, and no interpolation is performed.
The LUTSelector parameter allows you to select a lookup table.
Because there is only one user-defined lookup table available on Basler cameras, the parameter currently serves no function.
Camera Model | Number of LUT Entries |
---|---|
All ace 2 GigE camera models | LUT feature not supported |
All ace 2 USB 3.0 camera models | LUT feature not supported |
All ace USB 3.0 camera models except MED models | 512 |
All ace GigE camera models except MED models | 512 |
All MED ace GigE camera models | 1 024 |
All MED ace USB 3.0 camera models | 4 096 |
All boost CXP-12 camera models | LUT feature not supported |
All dart BCON for LVDS camera models | LUT feature not supported |
All dart BCON for MIPI camera models | LUT feature not supported |
All dart USB 3.0 camera models | LUT feature not supported |
All pulse USB 3.0 camera models | LUT feature not supported |
// Write a lookup table to the device.
// 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 bit
for (int i=0; i<4096; i+=8)
{
camera.LUTIndex.SetValue(i);
camera.LUTValue.SetValue(4095-i);
}
// Enable the LUT
camera.LUTEnable.SetValue(true);
This sample code is available in C++ language only.
You can also use the pylon Viewer to easily set the parameters.