У меня есть дорожные фотографии из гоночной игры.![enter image description here](https://i.stack.imgur.com/pw12b.jpg)
Я хочу обнаружить желтые и белые полосы.Если я использую пространство RGB,
def select_rgb_white_yellow(image):
# white color mask
lower = np.uint8([123, 116, 116])
upper = np.uint8([186, 172, 160])
white_mask = cv2.inRange(image, lower, upper)
# yellow color mask
lower = np.uint8([134, 121, 100])
upper = np.uint8([206, 155, 87])
yellow_mask = cv2.inRange(image, lower, upper)
# combine the mask
mask = cv2.bitwise_or(white_mask, yellow_mask)
masked = cv2.bitwise_and(image, image, mask = mask)
return masked
![enter image description here](https://i.stack.imgur.com/UAk1t.png)
, я получаю только белые полосы.Так немного подправил, используя пространство HLS, используя этот код.
def convert_hls(image):
return cv2.cvtColor(image, cv2.COLOR_RGB2HLS)
![enter image description here](https://i.stack.imgur.com/9q9hP.jpg)
Затем, снова извлекая желтую и белую полосы,
def select_white_yellow(image):
converted = convert_hls(image)
# white color mask
lower = np.uint8([0, 0, 0])
upper = np.uint8([0, 0, 255])
white_mask = cv2.inRange(converted, lower, upper)
# yellow color mask
lower = np.uint8([ 10, 0, 100])
upper = np.uint8([ 40, 255, 255])
yellow_mask = cv2.inRange(converted, lower, upper)
# combine the mask
mask = cv2.bitwise_or(white_mask, yellow_mask)
return cv2.bitwise_and(image, image, mask = mask)
![enter image description here](https://i.stack.imgur.com/n4FBJ.png)
Тогда он больше не сможет обнаружить белую полосу движения.Есть ли хороший способ обнаружить как белую, так и желтую полосу?
Вот весь код цвета RGB, который я нашел
Yellow
c2974A (194, 149, 74)
a07444 (160, 116, 68)
b38e55 (179, 142, 85)
867964 (134, 121, 100)
ce9b57 (206, 155, 87)
ce9853 (206, 152, 83)
white
b4a59d (180, 165, 157)
b9a99a (185, 169, 154)
baaca0 (186, 172, 160)
867e79 (134, 126, 121)
7b7474 (123, 116, 116)
827d7c (130, 125, 124)