RuiQi
RuiQi

Reputation: 488

How to determine if color at a certain pixel is "white"?

Given an image, how do I go about determining if a certain pixel is "white" ? Based on Wikipedia, I understand that if the RGB values are at (255,255,255), the pixel is considered white and that a lower similar set of values for eg. (200,200,200) would mean that it is a "darker shade of white" i.e. gray.

Should I just set a threshold of example 80% for each channel and if the RGB at a certain pixel passes that condition then it is marked as gray/white ? Are there any papers that I can read up for help ?

Regards, Haziq

Upvotes: 1

Views: 1512

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207540

If you simply threshold all channels at, say 200, you are allowing the Red to differ from the Green and that to differ from the Blue, which means you are allowing colour into your images and all the following colours would be permitted:

enter image description here

You need to ensure that, not only are Red, Green and Blue above 200, but further that they are equal. That way you only permit this range:

enter image description here

In the HSL model, you need Lightness to be above say 80%, but also the Saturation to be zero to ensure white/gray.

Upvotes: 1

Balaji R
Balaji R

Reputation: 1845

The solution is to convert your color space from RGB to HSV. Here is sample algorithm thread. Finally apply threshold in Value (Lightness) Channel to filter bright region.

Upvotes: 1

Related Questions