The following is the code i had entered in the Spyder Environment :
import os
import cv2
import numpy as np
path1="E:\\academic\\FINAL YR PROJ\\PROJECT_DATASETS\\floyd_jan\\dr"
path2="E:\\academic\\FINAL YR PROJ\\PROJECT_DATASETS\\floyd_jan\\greendr"
names=[]
names=os.listdir(path1)
for i in names:
bgr = cv2.imread(path1+"\\"+i,1)
green = bgr[: , : , 1]
lab = cv2.cvtColor(green, cv2.COLOR_BGR2LAB)
lab_planes = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(8,8))
lab_planes[0] = clahe.apply(lab_planes[0])
lab = cv2.merge(lab_planes)
bgr = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)
cv2.imwrite(path2+"\\"+i,bgr)
I am getting the following error on running the code :
Traceback (most recent call last):
File "", line 8, in lab = cv2.cvtColor(green, cv2.COLOR_BGR2LAB)
error: C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:10724: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cv::cvtColor
Unable to figure out the solution!