I know that the easiest way to segment certain color is using the HSV color space, but I have a task to do it in HSV, RGB and Lab... I am really confused how to do it in Lab. I did it in HSV and it's really simple. Here's the function that segments human color using the HSV color space
import cv2
import matplotlib.pyplot as plt
import numpy as np
def HSV_Segmentation(image):
lowerRange= np.array([0, 70, 0] , dtype="uint8")
upperRange= np.array([25, 255, 255], dtype="uint8")
mask = image[:].copy()
imageHSV = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
imageRange = cv2.inRange(imageHSV,upperRange, lowerRange)
mask[:,:,0] = imageRange
mask[:,:,1] = imageRange
mask[:,:,2] = imageRange
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5))
closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)
faceHSV = cv2.bitwise_and(image,mask)
return faceHSV
And now I'm stuck at Lab color space,and I am not really sure where to begin. I tried something similar with upper and lower range of human color but obviously that's not the right way.