MATLAB: Lookup into array given a matrix (just replacing the values of matrix by vector)

fastest way to search in lookup tableimage processingImage Processing Toolboxlookup tablereplace the values of matrix by vector values

Hi everyone,
I have a very big matrix R of uint8. For every element (0-255) I have an other value in array A, where A is 256 length vector.
Now How can I replace each element in R by their lookup value in A. I want to do it as fast as it can.

Best Answer

The function you want to use is called intlut() and it's in the Image Processing Toolbox. It's fast and is just a single line of code.
new_R = intlut(R, A);