我使用python和opencv在此示例图像上通过HSV检测皮肤:
# "org" is the original image, i convert it to HSV color and save in "frame"
frame = cv2.cvtColor(org, cv2.COLOR_BGR2HSV)
# then using "cv2.inRange" to find skin part
v1_min, v2_min, v3_min = 6, 36, 89
v1_max, v2_max, v3_max = 27, 255, 255
skinmask = cv2.inRange(frame, (v1_min, v2_min, v3_min), (v1_max, v2_max, v3_max))
clothmask = 255 - skinmask
# save skin part of image in "skin" and others in "cloth"
cloth = cv2.bitwise_and(org, org, mask=clothmask)
skin = cv2.bitwise_and(org, org, mask=skinmask)
# color around the skin is black after mask apply.
#so change it to a color near white human skin color to prevent black edges after blur
skin[skinmask == 0] = (24 * 5, 35 * 5, 220)
# now blur the skin part
skin = cv2.blur(skin, (30, 30))
# apply "skinmask" to skin part after blur
skin = cv2.bitwise_and(skin, skin, mask=skinmask)
# put the cloth and skin together
result = cv2.bitwise_or(skin, cloth)
我不知道为什么皮肤边缘太差了。 不知道问题是来自我的皮肤选择方法还是模糊或其他什么?
由于