Janusz
Janusz

Reputation: 189594

How to isolate a single color in an image

I'm using the python OpenCV bindings and at the moment I try to isolate a colorrange. That means I want to filter out everything that is not reddish.

I tried to take only the red color channel but this includes the white spaces in the Image too.

What is a good way to do that?

Upvotes: 1

Views: 3302

Answers (3)

Jive Dadson
Jive Dadson

Reputation: 17056

Use the HSV colorspace. Select pixels that have an H value in the range that you consider to contain "red," and an S value large enough that you do not consider it to be neutral, maroon, brown, or pink. You might also need to throw out pixels with low V's. The H dimension is a circle, and red is right where the circle is split, so your H range will be in two parts, one near 255, the other near 0.

Upvotes: 1

Niki
Niki

Reputation: 15867

How about using a formular like r' = r-(g+b)?

Upvotes: 0

Dave
Dave

Reputation: 10575

Use a different color space: http://en.wikipedia.org/wiki/HSL_color_space

Upvotes: 4

Related Questions