Range of HSV values to sample an Image as done by adobe

Issue

I have an image as shown in the inset. I sampled it in Adobe Photoshop using the blue color as the image shows. The sampled image is shown in gray-scale on the left.

I know that openCV provides a similar method to sample images that is the inRange() function. How can I find out the range of HSV values that Adobe checked for to sample my image. Since the resultant image is pretty much what I want and I am not able to determine the range myself It would be a great help if some one could guide me for the same.

Photoshop Sampled

Solution

You can convert your image in HSV with cv::cvtColor(...) here the documentation

Then accordingly to Wikipedia the blue is near to 240° of the HUE channel of your image.
You can set something like maxHue = 270 and a minHue = 180 or other values to scan your image.

Maybe you should set a minSaturation and a minValue to avoid the black and white.

To find the best ranges you can link them with some sliders in a Qt GUI and change them until you get the same result as photoshop…

Answered By – Michele mpp Marostica

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published