我想用cv2 LUT在Python中执行图像传输。 LUT需要与图像具有相同数量的通道。但我解决不了一个错误:多通道LUT opencv2 python声明错误
image1Transfered = cv2.LUT(image1, lut) cv2.error: /build/buildd/opencv-2.3.1/modules/core/src/convert.cpp:1037: error: (-215) (lutcn == cn || lutcn == 1) && lut.total() == 256 && lut.isContinuous() && (src.depth() == CV_8U || src.depth() == CV_8S) in function LUT
这里是Python代码,我相信我能分割图像到多个单通道和分别适用的LUT。但这是资源的浪费。
#!/usr/bin/python
import sys
import cv2
import numpy as np
image1 = cv2.imread("../pic1.jpg", 1)
# apply look up table
lut = np.arange(255, -1, -1, dtype = image1.dtype)
lut = np.column_stack((lut, lut, lut))
image1Converted = cv2.LUT(image1, lut) # <-- this is where it fails
谢谢你的时间。