Ask Your Question
0

cv::inRange higher bound out of range of 0-180 in HSV

asked 2019-04-02 08:48:54 -0600

Jendker gravatar image

I am working on segmenting the image based on the colour.

Right now I am considering how the cv::inRange function performs if my upper range of specific channel will be higher than max. value if 180, while the actual value on image will be close to 0?

Please let me present an example in HSV colour space: I have the filter with lowerb = (170, 50, 50), upperb = (190, 255, 255). Here I want to detect pink colour, which comes further into orange, so that the points of H are slightly above 0.

In the given case will the point (5, 180, 180) get accepted, so that cv::inRange will append the points above 0? Or should I apply two inRange filters:

lowerb = (170, 50, 50), upperb (179, 255, 255)
lowerb = (0, 50, 50), upperb (10, 255, 255)

and sum the results to achieve what I need?

I was trying to find the answer to my question in the OpenCV source code, but it was rather difficult to understand...

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-04-02 09:58:05 -0600

berak gravatar image

no, you can't i have a range from 170 to 10,

and yes, you need 2 sets of ranges (like in the question), and 2 inRange() calls.

then, you probably want to bitwise_or() the results, not sum them.

edit flag offensive delete link more

Comments

Thank you!

Jendker gravatar imageJendker ( 2019-04-02 10:18:28 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-02 08:48:54 -0600

Seen: 691 times

Last updated: Apr 02 '19