You can do the mapping by using cvLUT or cv::LUT (C/C++)

http://docs.opencv.org/modules/core/doc/operations_on_arrays.html?highlight=lut#lut

Calling the function is trivial and is explained in the documentation.

Answer from Hristo Hristov on Stack Overflow
🌐
OpenCV
docs.opencv.org › 4.13.0 › db › da5 › tutorial_how_to_scan_images.html
OpenCV: How to scan images, lookup tables and time measurement with OpenCV
Therefore, for larger images it would be wise to calculate all possible values beforehand and during the assignment just make the assignment, by using a lookup table. Lookup tables are simple arrays (having one or more dimensions) that for a given input value variation holds the final output value.
🌐
GitHub
github.com › Milchreis › OpenCV-LUT-Editor
GitHub - Milchreis/OpenCV-LUT-Editor: Tool to create freehand color correction lookup tables for OpenCV · GitHub
Tool to create freehand color correction lookup tables for OpenCV Implemented in Processing for OpenCV and experimentational research.
Author: Milchreis
🌐
OpenCV
docs.opencv.org › 4.13.0 › d4 › d62 › group__core__hal__interface__lut.html
OpenCV: Lookup table
Lookup table replacement Table consists of 256 elements of a size from 1 to 8 bytes having 1 channel or src_channels For 8s input type 128 is added to LUT index Destination should have the same element type and number of channels as lookup table elements
🌐
OpenCV
docs.opencv.org › 4.13.0 › d1 › d55 › group__core__hal__interface__lut16.html
OpenCV: Lookup table for 16 bit index
Lookup table replacement Table consists of 65536 elements of a size from 1 to 8 bytes having 1 channel or src_channels For 16s input typea 32768 is added to LUT index Destination should have the same element type and number of channels as lookup table elements · Parameters · See also · LUT · #include <core/src/hal_replacement.hpp> Generated on Wed Dec 31 2025 07:26:23 for OpenCV by 1.12.0
🌐
YouTube
youtube.com › watch
Creating Advance Color Filters using Lookup Tables in OpenCV | Creating Instagram Filters - Pt ⅔ - YouTube
In this video, you will learn what LookUp Tables are, why are they preferred along with their use cases in real-life, and then utilize these LookUp Tables to...
Published: February 10, 2022
🌐
YouTube
youtube.com › marearts
OpenCV Lecture - 4. point processing (8/8) : Fast Lookup Table - YouTube
Material:https://www.marearts.comLectures ▸ OpenCV ▸ ch4+ What is LUT+ applyColorMap+ make own LUT***********************************************************
Published: March 9, 2017
Views: 1K
Find elsewhere
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 11379 › how-to-build-lookup-table-for-inverse-perspective-mapping
How to build lookup table for inverse perspective mapping? - OpenCV Q&A Forum
April 11, 2013 - Hi, I want to build a lookup table to use with inverse perspective mapping. Instead of applying warpPerspective with the transform matrix on each frame, I want to use a lookup table (LUT). Right now I use the following code to generate the transformation matrix m = new Mat(3, 3, CvType.CV_32FC1); m = Imgproc.getPerspectiveTransform(src, dst); In the onCameraFrame() I apply the warpPerspective() function.
🌐
OpenCV
forum.opencv.org › python
Lookup table error - Python - OpenCV
February 19, 2024 - import cv2 as cv import numpy as np import matplotlib.pyplot as plt img = cv.imread('images/spider.png', cv.IMREAD_COLOR) img = cv.cvtColor(img, cv.COLOR_BGR2RGB) h, s, v = cv.split(cv.cvtColor(img, cv.COLOR_RGB2HSV)) sigma = 70 a = np.arange(0, 1, 0.1) for value_a in a: func = np.minimum(s + value_a * 128 * np.exp(-(s - 128) ** 2 / (2 * sigma ** 2)), 255) s = s.astype(np.uint8) s_new = cv.LUT(s, func) img_new = cv.cvtColor(cv.mer...
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 51356 › lookup-table-for-16-bit-images
LookUp Table for 16-Bit Images - OpenCV Q&A Forum
November 23, 2014 - main() { Size Img_Size(320,240); Mat Img_Source_16(Size(320,240),CV_16UC1,Scalar::all(0)); Mat Img_Destination_16(Size(320,240),CV_16UC1,Scalar::all(0)); unsigned short LookupTable[4096]; for (int i = 0; i < 4096; i++) { LookupTable[i]= 4096-i; } int i=0; for (int Row = 0; Row < Img_Size.height; Row++) { for (int Col = 0; Col < Img_Size.width; Col++) { Img_Source_16.at<short>(Row,Col)= i; i++; if(i>=4095) i=0; } } imshow("Img_Source",Img_Source_16); t1.start(); Img_Destination_16= ScanImageAndReduceC_16UC1(Img_Source_16.clone(),LookupTable); imshow("Img_Destination",Img_Destination_16); t1.sto
🌐
Weiy
weiy.city › 2019 › 11 › scale-image-by-lookup-table
OpenCV Changes Image Color By Lookup Table
November 19, 2019 - We cannot provide a description for this page right now
Authors: David Millán EscriváRobert Laganiere
Published: 2019
Pages: 494
🌐
Packt
packtpub.com › en-us › product › learning-opencv-3-application-development-9781784391454 › chapter › 1-laying-the-foundation-1 › section › lookup-tables-ch01lvl1sec09
Lookup tables
If we do so, then irrespective of the dimensions (number of pixels) in our input image, we will never need more than 256 computations. So, using this strategy, we traverse our matrix and do a simple lookup of the pre-computed values. This is ...