Main Content

intlut

Convert integer values using lookup table

Description

example

B= intlut(A,lut)converts values in arrayAbased on lookup tablelutand returns these new values in arrayB.

Examples

collapse all

Create an array of integers.

A = uint8([1 2 3 4; 5 6 7 8; 9 10 0 1])
A =3x4 uint8 matrix1 2 3 4 5 6 7 8 9 10 0 1

Create a lookup table. In this example, the lookup table is created by following the vector [2 4 8 16] with repeated copies of the vector [0 150 200 250].

LUT = [2 4 8 16 repmat(uint8([0 150 200 255]),1,63)];

Convert the values of A by referring to the lookup table. Note that the first index of the lookup table is 0.

B = intlut(A, LUT)
B =3x4 uint8 matrix4 8 16 0 150 200 255 0 150 200 2 4

Input Arguments

collapse all

Input matrix, specified as an array of integers.

Data Types:int16|uint8|uint16

Lookup table, specified as a vector of integers.

  • IfAhas data typeuint8, thenlutmust be auint8vector with 256 elements.

  • IfAhas data typeuint16orint16, thenlutmust be a vector with 65536 elements of the same class asA.

Data Types:int16|uint8|uint16

Output Arguments

collapse all

Converted matrix, returned as an array of integers.Bhas the same size and data type asA.

Data Types:int16|uint8|uint16

Algorithms

  • WhenAhas data typeuint8oruint16, an offset of 1 is applied when indexing into the lookup table. For example, if an element ofAhas the valuealpha, then the corresponding element inBhas the valuelut(alpha+1).

  • WhenAhas data typeint16, an additional offset of 32768 is applied to the lookup table index. For example, if an element ofAhas the valuealpha, then the corresponding element inBhas the valuelut(alpha+ 32768 + 1)。

Extended Capabilities

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced before R2006a

See Also

|