Ask Your Question

Terrible Child's profile - activity

2020-04-19 13:55:57 -0500 received badge  Notable Question (source)
2018-03-24 13:45:39 -0500 received badge  Popular Question (source)
2015-01-30 05:52:44 -0500 asked a question inRange with HSV values

I was wondering how to use inRange function with HSV values as range instead of RGB.

Mat image = imread("pic.png", 1);
Mat mask = Mat::zero(image.size(), 8UC3);
Mat output = image.clone();

Scalar min = Scalar(20, 50, 50); //HSV VALUE
Scalar max = Scalar(25, 255, 255); //HSV VALUE
Scalar blue = Scalar(255, 0, 0);  //BGR VALUE
inRange(image, min, max, mask);
output.setTo(blue, mask);

The inRange function seem to take in BGR values but not HSV. How would I go about modifying the code so that inRange would filter by HSV?