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 OverflowOpenCV
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.
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
Jancy Standard Library
vovkos.github.io › doxyrest-showcase › opencv › sphinx_rtd_theme › class_cv_cuda_LookUpTable.html
class cv::cuda::LookUpTable — OpenCV Documentation
Base class for transform using lookup table.
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
OpenCV
docs.opencv.org › 3.4 › df › d29 › classcv_1_1cuda_1_1LookUpTable.html
OpenCV: cv::cuda::LookUpTable Class Reference
Base class for transform using lookup table.
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
Top answer 1 of 2
1
try
unsigned short* p = (unsigned short*) lookUpTable.data;
2 of 2
0
OpenCV LUT is working just with CV_8U, so what you can do is splitting the numbers in 3, that is 3x CV_8U, or CV_8UC3. But you cannot have more than 256 elements in the LUT and not other values than 0..255 as index.
In other words, you can parse uchars to uchars or uchars to floats: CV_8UC1 -> CV_8UC1 or CV_8UC1 -> CV_8UC3 (I did not tried it whit CV_8UC4, it could work).
For getting the elements of CV_8UC3 check cv::Vec3b
I found this, that might interest you
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
Packtpub
subscription.packtpub.com › book › data › 9781784391454 › 1 › ch01lvl1sec14 › lookup-tables
Learning OpenCV 3 Application Development
1. Laying the Foundation. A chapter from Learning OpenCV 3 Application Development by Samyak Datta