How to find the ranges for color in HSV method?

Hello,
I find a 'Track color in video.zip' (provided by Image Analyst) from the following website.
In the 40-42 rows of 'track_color_in_video.m', the following contents are given to detect green color.
hThresholds = [0.24, 0.44];
sThresholds = [0.8, 1.0];
vThresholds = [20, 125];
I am confused about:
1. the HSV parameters in Matlab ranges from 0 to 1, why the v parameter is different while this code runs well?
2. I notice the image analyst provides the 'color inspector 3D'. I do not have JAVA(required for this software) installed in my computer. Is there another method to give proper HSV parameter ranges for any color? Or just provide the ranges for red, blue, green colors to be used in this code?
Thanks for your time.

 Accepted Answer

The ranges correspond to data that's scaled [0 255], not [0 1].
hsv = rgb2hsv(double(thisFrame));
Note that he's using double(), not im2double(), so the image isn't rescaled. It's a floating point image, but it's still scaled [0 255]. When this gets transformed by rgb2hsv(), the results for V will be on a similar scale. H won't be, because angle is invariant of scale, and S won't be, because it's a relative measure.
I haven't used ImageJ's color inspector, but if you're looking to display the color point cloud in different color spaces, the Color Thresholder app (should be installed if you have IPT) starts with a point cloud view in RGB, HSV, LAB, and YCbCr. You may be able to use that for tuning your limits.

1 Comment

Dear DGM,
Thanks for your detailed explanation. Now I got it. The 'Color Thresholder app' is excellent to tune HSV/RGB component limits.
I really appreicate your sincere support.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 3 May 2021

Commented:

on 5 May 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!