HSV Color Segmentation

HSV segmentation isolates colors by thresholding hue, saturation, and value.

import cv2
import numpy as np


def hsv_segment(img):
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
lower = np.array([0, 50, 50])
upper = np.array([10, 255, 255])
return cv2.inRange(hsv, lower, upper)
← Back to Gallery