Main Content

intlut

Convert integer values using lookup table

Description

B = intlut(A,lut) converts values in array A based on lookup table lut and returns these new values in array B.

example

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 matrix

    1    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 matrix

     4     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.

  • If A has data type uint8, then lut must be a uint8 vector with 256 elements.

  • If A has data type uint16 or int16, then lut must be a vector with 65536 elements of the same class as A.

Data Types: int16 | uint8 | uint16

Output Arguments

collapse all

Converted matrix, returned as an array of integers. B has the same size and data type as A.

Data Types: int16 | uint8 | uint16

Algorithms

  • When A has data type uint8 or uint16, an offset of 1 is applied when indexing into the lookup table. For example, if an element of A has the value alpha, then the corresponding element in B has the value lut(alpha+1).

  • When A has data type int16, an additional offset of 32768 is applied to the lookup table index. For example, if an element of A has the value alpha, then the corresponding element in B has the value lut(alpha+32768+1).

Extended Capabilities

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

Version History

Introduced before R2006a

expand all

See Also

|