Skip to content Skip to sidebar Skip to footer

Apply Opencv Look Up Table (lut) To An Image

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 -*- impor

Solution 1:

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;

Post a Comment for "Apply Opencv Look Up Table (lut) To An Image"