HSV is cylindrical color space that determines colors by hue (0°-360°), saturation (percentage of white) and value (percentage of black).
Questions tagged [hsv]
468 questions
228
votes
20 answers
How to compare two colors for similarity/difference
I want to design a program that can help me assess between 5 pre-defined colors which one is more similar to a variable color, and with what percentage. The thing is that I don't know how to do that manually step by step. So it is even more…

Ana Fernandes
- 2,281
- 2
- 14
- 4
113
votes
10 answers
Choosing the correct upper and lower HSV boundaries for color detection with`cv::inRange` (OpenCV)
I have an image of a coffee can with an orange lid position of which I want to find.
Here is it .
gcolor2 utility shows HSV at the center of the lid to be (22, 59, 100).
The question is how to choose the limits of the color then? I tried min = (18,…

Student FourK
- 1,323
- 2
- 10
- 6
72
votes
7 answers
How to Convert RGB Color to HSV?
How can I convert a RGB Color to HSV using C#?
I've searched for a fast method without using any external library.

Tom Smykowski
- 25,487
- 54
- 159
- 236
64
votes
5 answers
HSB vs HSL vs HSV
I am making a Color class as a part of a very basic graphics API in c++. So I decided to take a look at Microsoft's .NET framework and noticed that their Color class has functions for HSB.
Then I started a research to determine whether I should…

Giwrgos Tsopanoglou
- 1,165
- 2
- 8
- 15
52
votes
6 answers
Javascript convert HSB/HSV color to RGB accurately
I need to accurately convert HSB to RGB but I am not sure how to get around the problem of turning decimals into whole numbers without rounding. This is the current function I have out of a colorpicker library:
HSBToRGB = function (hsb) {
var…

that_guy
- 2,313
- 4
- 33
- 46
48
votes
10 answers
HSV to RGB Color Conversion
Is there a way to convert HSV color arguments to RGB type color arguments using pygame modules in python? I tried the following code, but it returns ridiculous values.
import colorsys
test_color = colorsys.hsv_to_rgb(359, 100,…

AvZ
- 997
- 3
- 14
- 25
38
votes
3 answers
Finding red color in image using Python & OpenCV
I am trying to extract red color from an image. I have code that applies threshold to leave only values from specified range:
img=cv2.imread('img.bmp')
img_hsv=cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
lower_red = np.array([0,50,50]) #example…

yolo77
- 383
- 1
- 3
- 7
36
votes
3 answers
Tracking white color using python opencv
I would like to track white color using webcam and python opencv. I already have the code to track blue color.
_, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# define range of blue color in HSV
lower_blue =…

user3429616
- 371
- 1
- 4
- 8
34
votes
2 answers
From RGB to HSV in OpenGL GLSL
I need to pass from RGB color space to HSV .. I searched in internet and found two different implementations, but those give me different results:
A:
precision mediump float;
vec3 rgb2hsv(float r, float g, float b) {
float h = 0.0;
float…

BQuadra
- 789
- 2
- 11
- 20
32
votes
4 answers
Why is the range of hue 0-180° in opencv
Can anybody explain to me why the hue value of an HSV image in OpenCV only goes to 180° and not the full 360°?
I have found somewhere that OpenCV uses a 180° cylinder, but I can not really visualize such a cylinder.
Thanks in advance!
J

JasperV
- 656
- 1
- 9
- 19
27
votes
3 answers
How to change hue of a texture with GLSL?
Is there a way to efficiently change hue of a 2D OpenGL texture using GLSL (fragment shader)?
Do someone have some code for it?
UPDATE: This is the code resulting from user1118321 suggestion:
uniform sampler2DRect texture;
const mat3 rgb2yiq =…

Andrea3000
- 1,018
- 1
- 11
- 26
24
votes
5 answers
RGB to HSV in PHP
In PHP, what is the most straightforward way to convert a RGB triplet to HSV values?

Alix Axel
- 151,645
- 95
- 393
- 500
20
votes
4 answers
Why does greyscale work the way it does?
My original question
I read that to convert a RGB pixel into greyscale RGB, one should use
r_new = g_new = b_new = r_old * 0.3 + g_old * 0.59 + b_old * 0.11
I also read, and understand, that g has a higher weighting because the human eye is more…

Delan Azabani
- 79,602
- 28
- 170
- 210
20
votes
1 answer
Convert RGB value to HSV
I've found a method on the Internet to convert RGB values to HSV values.
Unfortunately, when the values are R=G=B, I'm getting a NaN, because of the 0/0 operation.
Do you know if there is an implemented method for this conversion in Java, or what do…

marionmaiden
- 3,250
- 8
- 33
- 50
19
votes
5 answers
Sorting a list of RGB triplets into a spectrum
I have a list of RGB triplets, and I'd like to plot them in such a way that they form something like a spectrum.
I've converted them to HSV, which people seem to recommend.
from PIL import Image, ImageDraw
import colorsys
def…

Jason Sundram
- 12,225
- 19
- 71
- 86