Ask Your Question
0

Python cv2 inRange : how to segment "reddish" colors in HSV space

asked 2020-04-03 22:41:25 -0500

Hi,

I am creating a skin detection computer vision script. I looked at the examples in pyimagesearch and youtube, they use the cv2.inrange() function on HSV color space. However , they used hard coded values for the ranges and that makes their example only able to detect "white" or "black" skin colors.

I tried to use it to detect an "Orange"(asian) skin color, i sampled a region of orange skin and found that it has a hue value of 170 degrees to 20 degrees(reddish). However, the inrange function cannot detect this range because it spills over the 180 to 0 degrees boundary. How do i detect the orange skin color?

Thanks a lot

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-04-04 02:00:30 -0500

berak gravatar image

you can use 2 inRange() calls, one with hue going from 170 to 180, and another going from 0 to 20

then you can OR the resulting masks like:

final = cv2.bitwise_or(mask1, mask2)
edit flag offensive delete link more

Comments

Thanks a lot berak. I try it =)

Abeltan gravatar imageAbeltan ( 2020-04-05 01:11:38 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-04-03 22:41:25 -0500

Seen: 756 times

Last updated: Apr 04 '20