0

enter image description here

I'm trying to extract the colour grey from an image but I can't find the HSV upper and lower values for grey. I'm planning on using the cv.inRange function to extract the grey colour from the image. The RGB value for the shade of grey is (129,129,129), is there any colour picker that can be used to get the openCv HSV value for any colour and can anyone help identify the HSV value for grey.

I've attached the grey colour to the question. Thanks

h2lawal
  • 29
  • 3
  • Does https://alloyui.com/examples/color-picker/hsv.html helps you with the first part of your question? – SpiderPig1297 Oct 05 '20 at 23:27
  • @SpiderPig1297 - I've tried to use this before but this doesn't work on openCV, for RGB (129,129,129), the HSV values are (0,0,51) and this doesn't give the grey shade on openCv – h2lawal Oct 05 '20 at 23:38
  • Gray in HSV will have a saturation of 0 and a hue of 0. But note that the hue of black/white/all gray and red will all be 0. The value will be the intensity of the gray. Safer to do it in BGR as the gray will be (V,V,V) where V is the intensity or gray level. Just allow a range for either BGR or HSV to allow for any variations or compression fluctuations. In your case V=129. So BGR = (129,129,129) and HSV should be (0,0,129). – fmw42 Oct 05 '20 at 23:39
  • OpenCV use BGR not RGB. Though for grayscale it should not matter except you should read you image as BGR. The only issue would be if you convert from RGB to HSV, in general, you would get wrong values (other than for gray). – fmw42 Oct 05 '20 at 23:40
  • The answer is already available [here](https://stackoverflow.com/questions/53258628/how-to-i-specify-the-upper-and-the-lower-value-of-a-color-in-hsv-opencv-python). Just run the code, click on the grey part (any pixel) and the result will be displayed under the title `mask` – Ahmet Oct 06 '20 at 02:44

0 Answers0