# Revision history [back]

### Thresholding an HSV image

Hello, I have a skin detection code which get the skin region from an HSV image. I want to threshold it to a binary image. Here's a sample output-

I want the image on the right to be a binary image. The following snippet returns an error-

frame = cv2.resize(frame,(100,100))
converted = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

# using an elliptical kernel
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3,5))

# blur the mask to help remove noise, then apply the

#This is my addition that causes error
skin = cv2.cvtColor(skin,cv2.COLOR_HSV2BGR)
skin = cv2.threshold(skin,10,255,cv2.THRESH_BINARY )
skin = cv2.cvtColor(skin,cv2.COLOR_BGR2HSV)
# # show the skin in the image along with the mask
cv2.imshow("images", np.hstack([frame,skin]))


How do I get a binary version of skin image?

 2 retagged berak 32993 ●7 ●81 ●312

### Thresholding an HSV image

Hello, I have a skin detection code which get the skin region from an HSV image. I want to threshold it to a binary image. Here's a sample output-

I want the image on the right to be a binary image. The following snippet returns an error-

frame = cv2.resize(frame,(100,100))
converted = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

# using an elliptical kernel
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3,5))

# blur the mask to help remove noise, then apply the