L_GetFunctionalLookupTable

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_GetFunctionalLookupTable (pLookupTable, uLookupLen, uStart, uEnd, nFactor, uFlag)

L_INT L_FAR * pLookupTable;

/* lookup table */

L_UINT uLookupLen;

/* lookup table length */

L_UINT uStart;

/* first item */

L_UINT uEnd;

/* last item */

L_INT nFactor;

/* factor */

L_UINT uFlag;

/* flag */

Updates a range of entries in the lookup table, based on the specified mathematical function.

Parameter

Description

pLookupTable

Pointer to the lookup table to be filled by this function. The length of the lookup table is specified in the uLookupLen parameter.

uLookupLen

Length of the lookup table pointed to by the pLookupTable parameter. Possible values are:

 

Value

Meaning

 

65536

16-bit / sample image

 

4096

12-bit / sample image

 

256

8-bit / sample image

uStart

Index of the first entry in the lookup table to update. The indices of the table correspond to the intensity values.

uEnd

Index of the last entry in the lookup table to update. The indices of the table correspond to the intensity values.

nFactor

Value that indicates the factor to be applied in the function operation specified in the uFlag parameter. This parameter is used only if uFlag is FLT_EXP, FLT_SIGMOID or FLT_LN. If FLT_EXP or FLT_SIGMOID is set in uFlag the value of this parameter can be any integer (+/-). If FLT_LN flag is set, its value should be >= 0. However, if nFactor = 0 the lookup table will be filled linearly from uStart to uEnd, regardless of the value set in uFlag.

uFlag

Flag that indicates the function used to update the lookup table. Possible values are:

 

Value

Meaning

 

FLT_EXP

[0x0000] Apply the exponential function.

 

FLT_LN

[0x0001] Apply the natural logarithm function.

 

FLT_LINEAR

[0x0002] Apply the linear function.

 

FLT_SIGMOID

[0x0003] Apply the sigmoid function.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function will update the lookup table array using the predefined function specified in the uFlag parameter. In most cases, this function is used with the L_RemapBitmapIntensity function.

The nFactor parameter is used for log, exp and sigmoid functions only. If nFactor = 0 the function performs a linear interpolation between the two points uStart and uEnd and stores the results in the lookup table, regardless of the value set in uFlag.

If uFlag is FLT_EXP the value of nFactor modifies the lookup table values (see figure below) according to the following equations:

Y

=

uStart

+

(uEnd – uStart) * (exp ((nFactor/10.0 * (x-uStart))/(uEnd-uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where :

nFirstValue = exp(0).

nLastValue = exp(nFactor/10.0)

x = the intensity value of the selected point

image\WinLevel2.gif

If uFlag is FLT_LN the value of nFactor modifies the lookup table values (see figure below) according to the following equations:

Y

=

uStart

+

(uEnd – uStart) * (ln (1 + (nFactor/10.0 * (x-uStart))/(uEnd- uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where:

nFirstValue = 0.

nLastValue = ln(1 + nFactor/10.0)

x = the intensity value of the selected point

image\WinLevel1.gif

If uFlag is FLT_SIGMOID the value of nFactor modifies the lookup table values (see figure below) according to the following equations:

Y

=

uStart

+

(uEnd – uStart) * (1./ (1 + exp(2*nFactor/10. * (x-Center))/(uEnd- uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where:

nFirstValue = 1./(1+exp(2.*nFactor/10.*(nStart - Center)/ (uEnd- uStart))).

nLastValue = 1./(1+exp(2.*nFactor/10.*(nEnd - Center)/ (uEnd- uStart))).

Center = (nEnd + nStart)/2.

x = the intensity value of the selected point

 

image\WinLevel3.gif

If uFlag is FLT_LINEAR, nFactor is ignored. The function performs a linear interpolation between the two points uStart and uEnd and stores the results in the lookup table. The user determines the two points uStart and uEnd and their new values, nFirstValue and nLastValue. The value nFirstValue should be stored in the lookup table at the uStart position and nLastValue at the uEnd position of the lookup table before calling this function.

As an example, suppose a user wants to select a point, change the intensity value of that point (x), and then perform two linear interpolations:

image\sqrblit.gif from 0 to the intensity value x

image\sqrblit.gif from intensity value x to the end of the range

To accomplish this, the user would proceed by doing the following:

image\sqrblit.gif Select the point and get its intensity value (x)

image\sqrblit.gif Change the intensity value of the selected point to some new value (newCol).

image\sqrblit.gif Store the new intensity value in the Lookup table by assignment:

pLookupTable[x] = newCol;

image\sqrblit.gif Call L_GetFunctionalLookupTable with uStart set to 0, uEnd set to x, and uFlag set to FLT_LINEAR.

image\sqrblit.gif Call L_GetFunctionalLookupTable with uStart set to x, uEnd set to 255, and uFlag set to FLT_LINEAR. (For the example, assume the image is 8-bits per pixel.)

For another example, please refer to the example for L_RemapBitmapIntensity.

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

Required DLLs and Libraries

LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_GetUserLookupTable, L_RemapBitmapIntensity, L_ApplyVOILUT, L_AdjustBitmapTint, L_GammaCorrectBitmapExt

Topics:

Changing Brightness and Contrast

 

Raster Image Functions: Changing Brightness and Contrast

 

Raster Image Functions: Modifying Intensity Values

Example

/* This example will darken loaded bitmap by using lookup table affected by exponential function.*/

L_UINT LookupTable[256];  /* Array to hold lookup table*/
BITMAPHANDLE LeadBitmap;  /*Bitmap handle to hold the loaded image */

/* Load the bitmap, force 24 bits per pixel */
L_LoadBitmap
 (TEXT("IMAGE3.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL); 
/*Get Lookup table where the array calculated by the exponential function for all the items of the array  from 0 - 255*/
L_GetFunctionalLookupTable
 (LookupTable, 256,0, 255, 5, FLT_EXP);
L_RemapBitmapIntensity
 (&LeadBitmap, LookupTable, 256,CHANNEL_MASTER);