| Customize Help

Loading and generating data into LUTs



With MIL, you can generate data directly into a LUT buffer or calculate the data and then load it in a LUT buffer.

Generating data directly into the LUT buffer

You can generate general data directly into a LUT buffer, using MgenLutRamp() or MgenLutFunction().

The MgenLutRamp() function generates a value for each LUT index within the specified index range. The difference between the start value and the end value divided by (the number of entries specified by the index range - 1) produces the increment. The increment is then used to generate the remaining entries of the index range.

If the increment is positive, MgenLutRamp() generates a ramp. If the increment is negative, the function generates an inverse ramp. If the increment is equal to zero, it loads the entire LUT range with the given start value.

The MgenLutFunction() function generates a value for each LUT index within the specified index range according to a specified mathematical function. The functions available are: M_LOG, M_EXP, M_SIN, M_COS, M_TAN, and M_QUAD. The specified start value is used as the initial X value in the equation. The remaining entries of the index range are generated by incrementing the value of X by 1 for each index.

The MimHistogramEqualize() function can be used to create a LUT for intensity correction.

When generating data in a color LUT buffer, the same data is written to all bands.

To load each color band with different data, you would have to generate the data into three separate one-dimensional LUT buffers, then copy each buffer to the appropriate color band of the color LUT buffer, using MbufCopyColor().

Alternatively, you can allocate three separate one-dimensional child buffers into which the values for each color band will be generated. The use of child buffers will cause the values for each color band in the LUT buffer to be automatically updated and no copying is necessary.

Loading LUTs with precalculated data

There are several ways to generate more complex LUTs. Most of these, however, involve precalculating the data, then loading it into the LUT buffer:

  • Calculate data, using your Host system, and then load it into the LUT, using MbufPut(), MbufPut1d(), or MbufPutColor().

  • Generate data into another data buffer, using MIL functions other than MgenLutRamp() (for example, using the MimArith() function and perhaps the histogram of the image), then copy the data to the LUT buffer, using MbufCopy() or MbufCopyColor().

  • Load previously saved LUT data from disk to the LUT buffer (MbufLoad()). Note, when loading data from disk, there should be enough data for each dimension of the LUT buffer.

  • Restore a previously saved LUT, using MbufRestore(). Note, this function actually performs the LUT buffer allocation.