I'm filtering a RGB image (attached RGB image) with the inrange function to filter out all colors in my image except orange.
cv::Mat output;
cv::inRange(image, cv::Scalar(255, 140 , 0), cv::Scalar(255, 165, 0),output);
cv::imshow("output", output);
However all this does is return a black output. Additionally, I saw another question using the inrange function which used the values
cv::inRange(image, cv::Scalar(0, 125, 0), cv::Scalar(255, 200, 255), output);
and when I use these values it returns the right output. What is the difference here and What am I doing wrong?
The orange color in your image is (254, 165, 0). But more importantly, the images in OpenCV are in BGR order, so you need to do:
cv::inRange(image, cv::Scalar(0, 140, 254), cv::Scalar(0, 165, 254), output);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With