Ask Your Question

Revision history [back]

Open CV Error: Assertion failed (scn ==2 && depth == CV_8U) in cvtColor

Hi all,

I'm trying to read a 16-bit float exr image and convert it into grayscale for further image processing using openCV in python 2.7, however I encounter the above error "OpenCV Error: Assertion failed (scn == 2 && depth == CV_8U) in cvtColor"


Below is my code snippet

# load the image and convert it to grayscale

image = cv2.imread(args["image"],cv2.IMREAD_UNCHANGED)

gray = cv2.cvtColor(image, cv2.COLOR_BGR5552GRAY)


I have tried to use numpy to convert it to an unsigned 16-bit int using the below line but still am getting the same error

imageCopy = np.uint16(image)

I have tried to use cv2.COLOR_BGR5552GRAY , cv2.COLOR_BGR5652GRAY and cv2.COLOR_BGR2GRAY but to no avail.

Any help would be highly appreciated.

Thanks!