Below is an example of building LUT:
identity = np.arange(256, dtype = np.dtype('uint8'))
zeros = np.zeros(256, np.dtype('uint8'))
lut = np.dstack((identity, identity, zeros))
Note, there is much simpler and straightforward way zeroing the red channel:
img[:,:,2] = 0
Also calling LUT function should look like this:
dstImage = cv2.LUT(img, lut)
Set blue values greater than b_max to b_max:
b_max = 20
img[img[:,:,0] > b_max, 0] = b_max;
Answer from ivan_onys on Stack OverflowGitHub
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
Readthedocs
opencv-laboratory.readthedocs.io › en › latest › nodes › core › LUT.html
LUT — OpenCV Laboratory 1.0 alpha documentation
OpenCV Laboratory » · core » · LUT · Edit on GitHub · Performs a look-up table transform of an array. image_in – Input array of 8-bit elements.
python - Apply openCV Look Up Table (LUT) to an image - Stack Overflow
I want to apply a custom color look up table (LUT) on an image. I have looked over the openCV LUT Api but I can not seem to get it right. #!/bin/bash # -*- coding: utf-8 -*- import os import num... More on stackoverflow.com
Applying LUT on a cv::Mat - C++ - OpenCV
I’m trying to apply a LUT on a cv::Mat image. I read the documentation for cv::LUT here OpenCV: Operations on arrays but I don’t understand what “look-up table of 256 elements;” means: Is it that the LUT can have maximu… More on forum.opencv.org
Python Opencv cv2.LUT() how to use - Stack Overflow
Need to apply some rapid conversion on the color channels of a image. 1)I have stored in a list the corresponding output value: ListaVred = [0]*255 for i in range(0,255): ListaVred[i]=i*127 ... More on stackoverflow.com
[Question] Efficient LUT for 16 bit data type?
If you plan on manually setting you could use a dictionary and if the key exists modify else set to 0 More on reddit.com
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
In image processing it's quite common that you want to modify all of a given image values to some other value. OpenCV provides a function for modifying image values, without the need to write the scanning logic of the image. We use the cv::LUT() function of the core module.
LearnOpenCV
learnopencv.com › home › lut
LUT | LearnOpenCV
In this tutorial we will first show a simple way to pseudocolor / false color a grayscale image using OpenCV’s predefined colormaps.
OpenCV
docs.opencv.org › 4.13.0 › d2 › de8 › group__core__array.html
OpenCV: Operations on arrays
The function LUT fills the output array with values from the look-up table. Indices of the entries are taken from the input array.
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
Reddit
reddit.com › r/opencv › [question] efficient lut for 16 bit data type?
r/opencv on Reddit: [Question] Efficient LUT for 16 bit data type?
January 27, 2025 -
OpenCV LUT() apparently only supports 8 bit data types, so I've put together a numpy solution, my question is if this method can be improved upon, or made more efficient?
import cv2 import numpy as np image = np.zeros((5,5), dtype=np.uint16) image[1][1] = 1 image[2][2] = 5 lut = np.zeros((65535), dtype=np.uint16) lut[1] = 500 lut[5] = 1234 #new = cv2.LUT(image, lut) # LUT() is uint8 only? new = lut[image] # NP workaround for uint16 print(image) print(new) ... [[0 0 0 0 0] [0 1 0 0 0] [0 0 5 0 0] [0 0 0 0 0] [0 0 0 0 0]] [[ 0 0 0 0 0] [ 0 500 0 0 0] [ 0 0 1234 0 0] [ 0 0 0 0 0] [ 0 0 0 0 0]]
OpenCV Q&A Forum
answers.opencv.org › question › 70957 › lut-must-have-1-channel-or-the-number-of-channels-of-the-input-image
LUT must have 1 channel or the number of channels of the input image?!? - OpenCV Q&A Forum
September 16, 2015 - lut – look-up table of 256 elements; in case of multi-channel input array, the table should either have a single channel (in this case the same table is used for all channels) or the same number of channels as in the input array.
OpenCV
docs.opencv.org › 4.13.0 › d7 › d32 › lut_8hpp.html
OpenCV: opencv2/cudev/ptr2d/lut.hpp File Reference
Include dependency graph for lut.hpp: This graph shows which files directly or indirectly include this file: Generated on Wed Dec 31 2025 07:26:20 for OpenCV by 1.12.0
OpenCV Q&A Forum
answers.opencv.org › question › 206755 › lut-for-16bit-image
LUT for 16bit image - OpenCV Q&A Forum
Hi, I want to do lookuptable for 16 bit image. I have image of 16 bit(CV_16UC1), then i naormalize image with RGB give value and store in Mat variable called lut(type - CV_16UC3). After that, i split Mat lut and store in lut_channels. int planes = 3; vector lut_channels(planes); vector merge_elem; int glevl = 65535; int dim(glevl + 1); Mat lut(1, &dim, CV_16UC3); for (double j = 0; j (j)[0] = glevl*color*r; lut.at (j)[1] = glevl*color*g; lut.at (j)[2] = glevl*color*b; } split(lut, lut_channels); for (int k = 0; k
GitHub
github.com › Milchreis › OpenCV-LUT-Editor › blob › master › README.md
OpenCV-LUT-Editor/README.md at master · Milchreis/OpenCV-LUT-Editor
Tool to create freehand color correction lookup tables for OpenCV Implemented in Processing for OpenCV and experimentational research.
Author: Milchreis