Ask Your Question
0

Remove contour around a certain color

asked Jul 13 '16

updated Jan 19 '19

So i have a skin color range that I'm using to draw the contours of any skin color my camera sees, i.e, it'll draw contour on the hands or faces etc.

However, the range of color that I am using to draw the contours has a red range of 0-255, so it basically draws contour around everything that is red. The red pixel is however important for a good skin detection so I can't change that.

So i was wondering how I could tweek my contour code, so that it doesn't draw contour around the color red.

My code is as follow:

min_YCrCb = np.array([0,133,77],np.uint8) # Create a lower bound for the skin color
max_YCrCb = np.array([255,173,127],np.uint8) # Create an upper bound for skin color
skinRegion = cv2.inRange(converted,min_YCrCb,max_YCrCb) # Create a mask with boundaries
contours, hierarchy = cv2.findContours(skinRegion, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # Find the contour on the skin detection
    for i, c in enumerate(contours): # Draw the contour on the source frame
        area = cv2.contourArea(c)
        if area > 10000:
            cv2.drawContours(img, contours, i, (255, 255, 0), 2)
Preview: (hide)

Comments

just copy() your bgr image, draw contours into one, kep the other for further processing

berak gravatar imageberak (Jul 14 '16)edit

I'm not sure I understand what you mean, could you provide me with an example?

scunden gravatar imagescunden (Jul 14 '16)edit

1 answer

Sort by » oldest newest most voted
0

answered Jul 14 '16

elias gravatar image

Use the function cv::cvtColor to convert you image to type: CV_RGB2YCrCb.

Either Cb or Cr component has the skin colour in it separated from all other colours, I don't remember which, you can view the 3 different components in the yCbCr image separately to make sure which.

Kind regards.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jul 13 '16

Seen: 873 times

Last updated: Jul 13 '16