Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV select gray color range

Tags:

After reading these tutorials (this & this), I can figure out how to extract any color range including Red, Green, Blue and Yellow, using the Hue value of an HSV image or OpenCV Mat. However this value doesn't have the ability to describe the Gray color that I need to select. So is there any way to extract the Gray pixels of an image using OpenCV?

like image 706
peter bence Avatar asked Jun 12 '19 21:06

peter bence


1 Answers

In HSV/HSL colourspace, the grey pixels are characterised by having Saturation of zero or very close to zero, so that test will discriminate black through grey to white pixels. Then the Value/Lightness will tell you how far along the scale from black to white they actually are, low Lightness/Value is dark grey whereas high Lightness/Value means light grey.

In RGB colourspace, grey pixels are characterised by having all three colour components equal, i.e. R=G=B.

like image 146
Mark Setchell Avatar answered Sep 29 '22 07:09

Mark Setchell