Ask Your Question
0

Remove contour around a certain color

asked 2016-07-13 15:27:05 -0600

updated 2019-01-19 12:59:18 -0600

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)
edit retag flag offensive close merge delete

Comments

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

berak gravatar imageberak ( 2016-07-13 23:22:14 -0600 )edit

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

scunden gravatar imagescunden ( 2016-07-13 23:33:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-14 09:20:49 -0600

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-13 15:27:05 -0600

Seen: 753 times

Last updated: Jul 13 '16