The lookup table (LUT) transformations are basic image-processing functions that highlight details in areas containing significant information, at the expense of other areas. These functions include histogram equalization, gamma corrections, logarithmic corrections, and exponential corrections.

When to Use

Use LUT transformations to improve the contrast and brightness of an image by modifying the dynamic intensity of regions with poor contrast.

Concepts

A LUT transformation converts input gray-level values from the source image into other gray-level values in the transformed image.

A LUT transformation applies the transform T(x) over a specified input range [rangeMin, rangeMax] in the following manner:

  • T(x) = dynamicMin if x ≤ rangeMin
  • f(x) if rangeMin < x ≤ rangeMax
  • dynamicMax if x > rangeMax

where

  • x represents the input gray-level value,
  • dynamicMin = 0 (8-bit images) or the smallest initial pixel value (16-bit and floating point images),
  • dynamicMax = 255 (8-bit images) or the largest initial pixel value (16-bit and floating point images),
  • dynamicRange = dynamicMax - dynamicMin,
  • f(x) represents the new value.

The function scales f(x) so that f(rangeMin) = dynamicMin and f(rangeMax) = dynamicMax. f(x) behaves on [rangeMin, rangeMax] according to the method you select.

In the case of an 8-bit resolution, a LUT is a table of 256 elements. The index element of the array represents an input gray-level value. The value of each element indicates the output value.

The transfer function associated with a LUT has an intended effect on the brightness and contrast of the image.

Example

The following example uses the following source image. In the linear histogram of the source image, the gray-level intervals [0, 49] and [191, 254] do not contain significant information.

Using the following LUT transformation, any pixel with a value less than 49 is set to 0, and any pixel with a value greater than 191 is set to 255. The interval [50, 190] expands to [1, 254], increasing the intensity dynamic of the regions with a concentration of pixels in the gray-level range [50, 190].

I f   x 0 , 49 , F x = 0

I f   x 191 , 254 , f x = 225

e l s e F x = 1 . 81 × x - 89 . 5

The LUT transformation produces the following image. The linear histogram of the new image contains only the two peaks of the interval [50, 190].

Predefined Lookup Tables

Seven predefined LUTs are available in NI Vision: Linear, Logarithmic, Power 1/Y, Square Root, Exponential, Power Y, and Square. The following table shows the transfer function for each LUT and describes its effect on an image displayed in a palette that associates dark colors to low-intensity values and bright colors to high-intensity values, such as the Gray palette.

LUT Transfer Function Shading Correction

Linear

Increases the intensity dynamic by evenly distributing a given gray-level interval [min, max] over the full gray scale [0, 255]. Min and max default values are 0 and 255 for an 8-bit image.

Logarithmic Power1/Y Square Root

Increases the brightness and contrast in dark regions. Decreases the contrast in bright regions.

Exponential PowerY Square

Decreases the brightness and contrast in dark regions. Increases the contrast in bright regions.

Logarithmic and Inverse Gamma Correction

The logarithmic and inverse gamma corrections expand low gray-level ranges while compressing high gray-level ranges. When using the Gray palette, these transformations increase the overall brightness of an image and increase the contrast in dark areas at the expense of the contrast in bright areas.

The following graphs show how the transformations behave. The horizontal axis represents the input gray-level range, and the vertical axis represents the output gray-level range. Each input gray-level value is plotted vertically, and its point of intersection with the look-up curve is plotted horizontally to give an output value.

The Logarithmic, Square Root, and Power 1/Y functions expand intervals containing low gray-level values while compressing intervals containing high gray-level values.

The higher the gamma coefficient Y, the stronger the intensity correction. The Logarithmic correction has a stronger effect than the Power 1/Y function.

Logarithmic and Inverse Gamma Correction Examples

The following series of illustrations presents the linear and cumulative histograms of an image after various LUT transformations. The more the histogram is compressed on the right, the brighter the image.

Note Graphics on the left represent the original image, graphics on the top right represent the linear histogram, and graphics on the bottom right represent the cumulative histogram.

The following illustrations show the original image and histograms.

A Power 1/Y transformation (where Y = 1.5) produces the following image and histograms.

A Square Root or Power 1/Y transformation (where Y = 2) produces the following image and histograms.

A Logarithm transformation produces the following image and histograms.

Exponential and Gamma Correction

The exponential and gamma corrections expand high gray-level ranges while compressing low gray-level ranges. When using the Gray palette, these transformations decrease the overall brightness of an image and increase the contrast in bright areas at the expense of the contrast in dark areas.

The following graphs show how the transformations behave. The horizontal axis represents the input gray-level range, and the vertical axis represents the output gray-level range. Each input gray-level value is plotted vertically, and its point of intersection with the look-up curve is plotted horizontally to give an output value.

The Exponential, Square, and Power Y functions expand intervals containing high gray-level values while compressing intervals containing low gray-level values.

The higher the gamma coefficient Y, the stronger the intensity correction. The Exponential correction has a stronger effect than the Power Y function.

Exponential and Gamma Correction Examples

The following series of illustrations presents the linear and cumulative histograms of an image after various LUT transformations. The more the histogram is compressed, the darker the image.

Note  Graphics on the left represent the original image, graphics on the top right represent the linear histogram, and graphics on the bottom right represent the cumulative histogram.

The following illustrations show the original image and histograms.

A Power Y transformation (where Y = 1.5) produces the following image and histograms.

A Square or Power Y transformation (where Y = 2) produces the following image and histograms.

An Exponential transformation produces the following image and histograms.

Equalize

The Equalize function is a lookup table operation that does not work on a predefined LUT. Instead, the LUT is computed based on the content of the image where the function is applied.

The Equalize function alters the gray-level values of pixels so that they become evenly distributed in the defined grayscale range, which is 0 to 255 for an 8-bit image. The function associates an equal amount of pixels per constant gray-level interval and takes full advantage of the available shades of gray. Use this transformation to increase the contrast in images that do not use all gray levels.

The equalization can be limited to a gray-level interval, also called the equalization range. In this case, the function evenly distributes the pixels belonging to the equalization range over the full interval, which is 0 to 255 for an 8-bit image. The other pixels are set to 0. The image produced reveals details in the regions that have an intensity in the equalization range; other areas are cleared.

Equalization Example

This example shows how an equalization of the interval [0, 255] can spread the information contained in the three original peaks over larger intervals. The transformed image reveals more details about each component in the original image. The following graphics show the original image and histograms.

Note In Examples 1 and 2, graphics on the left represent the original image, graphics on the top right represent the linear histogram, and graphics on the bottom right represent the cumulative histogram.

An equalization from [0, 255] to [0, 255] produces the following image and histograms.

Note The cumulative histogram of an image after a histogram equalization always has a linear profile, as seen in the preceding example.

Equalization Example 2

This example shows how an equalization of the interval [166, 200] can spread the information contained in the original third peak (ranging from 166 to 200) to the interval [0, 255]. The transformed image reveals details about the component with the original intensity range [166, 200] while all other components are set to black. An equalization from [166, 200] to [0, 255] produces the following image and histograms.