【发布时间】:2013-05-16 03:31:09
【问题描述】:
我正在尝试使用 cv2 LUT 在 Python 中进行图像传输。 LUT 需要与图像具有相同数量的通道。但我无法解决一个错误:
image1Transfered = cv2.LUT(image1, lut) cv2.error: /build/buildd/opencv-2.3.1/modules/core/src/convert.cpp:1037: 错误: (-215) (lutcn == cn || lutcn == 1) && lut.total( ) == 256 && lut.isContinuous() && (src.depth() == CV_8U || src.depth() == CV_8S) 在函数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
感谢您的宝贵时间。
【问题讨论】: