Robust black cloth detection.

asked 2018-05-17 03:00:20 -0500

Santhosh1 gravatar image

updated 2018-05-18 01:26:28 -0500

My task requires detection of the black cloth in the beginning. I was trying to find a way to extract the black cloth from a few test case images.

Method 1

I first tried to convert the colour image the grayscale, then threshold the image to a particular level. Problem with this mention is due to the variation in the lighting conditions of images. I had a broad range of values from 40 - 140. Which requires a lot of manual intervention to detect the extract

I red a post on SO Estimate Brightness of an image Opencv, which mentions HSV colour good indicator of the brightness. I tried playing around with V in the HSV but was unable to find a good result.

I tried playing around withS in HSV which gave surprisingly good result, for my situation where I wanted to find the region I wanted to find my black cloth in. Value of S at 100,55 and 18 are giving good result in this particular order.

Having a hard time figuring out what exactly is happening here.

Can anyone help me explain how a black cloth is being detected in a HSV colour space just by changing S Value?

edit retag flag offensive close merge delete


If your initial image has colors, converting it to grayscale will reduce your chances. I suggest that you initially exclude colored parts of the picture. OpenCV has means to compare images. You can convert to grayscale and back, then compare pixel-by-pixel with initial source. If they aren't equal - this is a colored part.

ya_ocv_user gravatar imageya_ocv_user ( 2018-05-18 03:33:29 -0500 )edit

compareBGR with grayscale. How will I compare can you explain?

Santhosh1 gravatar imageSanthosh1 ( 2018-05-18 09:32:04 -0500 )edit