HSV (hue, saturation, value) is a color space created by a.r. Smith in 1978, also known as the hexcone model ). The color parameters in this model are: tone (H), saturation (s), and brightness (V ).
HSV Color Space Model[1]
Tone H: used for angle measurement. value range: 0 ° ~ 360 °. Start from the red color and start from the counter-clockwise direction. The red color is 0 °, the green color is 120 °, and the blue color is 240 °. Their complementary colors are: yellow is 60 °, blue is 180 °, and red is 300 °; saturation s: The value range is 0.0 ~ 1.0; brightness V: The value range is 0.0 (black )~ 1.0 (white ). Both the RGB and cmy color models are hardware-oriented, while the hue saturation value color model is user-oriented. The three-dimensional representation of the HSV model evolved from the RGB cube. We can see the hexagonal shape of the cube from the white vertices of RGB along the diagonal line of the cube to the Black vertices. The hexagonal border indicates color, the horizontal axis indicates purity, and the brightness is measured along the vertical axis. The h Parameter of the HSV six-Arn cone indicates the color information, that is, the location of the spectral color. This parameter is measured in one corner. The purity s of red, green, and blue is a proportional value, ranging from 0 to 1, it represents the ratio between the purity of the selected color and the maximum purity of the color. S = 0, only gray
HSV Color Space Model[2]
Degree. Separated by 120 degrees. The complementary colors differ by 180 degrees.
V indicates the brightness of the color, ranging from 0 to 1. Note that there is no direct connection between it and the light intensity.
HSV Color Space Model (cone model)[3]
The RGB color mode is a color standard in the industry) the changes of the three color channels and their overlapping to obtain a variety of colors, RGB represents the colors of the red, green, and blue channels, this standard covers almost all colors that human vision can perceive and is one of the most widely used color systems.
Introduction RGB color mode uses the RGB model to allocate a 0 ~ RGB weight for each pixel in the image ~ The intensity value within the range of 255. RGB Images use only three colors to mix them in different proportions and reproduce the 16777216 colors on the screen.
Color Conversion Algorithms
Contents
- RGB to HSV & HSV to RGB
- RGB to yiq & yiq to RGB
- RGB to XYZ & XYZ to RGB
- XYZ to cie l * a * B * (cielab) & cielab to XYZ
- XYZ to cieluv & cieluv to XYZ
RGB to HSV & HSV to RGB
The hue/saturation/value model was created by. r. smith in 1978. it is based on such intuitive color characteristics as tint, shade and tone (or family, purety and intensity ). the coordinate system is cylindrical,
And the colors are defined inside a hexcone. the hue value H runs from 0 to 360 °. the saturation S is the degree of strength or purity and is from 0 to 1. purity is how much white is added to the color, so S = 1 makes the purest color (no white ). brightness
V also ranges from 0 to 1, where 0 is the black.
There is no transformation matrix for RGB/HSV conversion, but the algorithm follows:
// r,g,b values are from 0 to 1// h = [0,360], s = [0,1], v = [0,1]//if s == 0, then h = -1 (undefined)
void RGBtoHSV( float r, float g, float b, float *h, float *s, float *v ){float min, max, delta;
min = MIN( r, g, b );max = MAX( r, g, b );*v = max;// v
delta = max - min;
if( max != 0 )*s = delta / max;// selse {// r = g = b = 0// s = 0, v is undefined*s = 0;*h = -1;return;}
if( r == max )*h = ( g - b ) / delta;// between yellow & magentaelse if( g == max )*h = 2 + ( b - r ) / delta;// between cyan & yellowelse*h = 4 + ( r - g ) / delta;// between magenta & cyan
*h *= 60;// degreesif( *h < 0 )*h += 360;
}
void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v ){int i;float f, p, q, t;
if( s == 0 ) {// achromatic (grey)*r = *g = *b = v;return;}
h /= 60;// sector 0 to 5i = floor( h );f = h - i;// factorial part of hp = v * ( 1 - s );q = v * ( 1 - s * f );t = v * ( 1 - s * ( 1 - f ) );
switch( i ) {case 0:*r = v;*g = t;*b = p;break;case 1:*r = q;*g = v;*b = p;break;case 2:*r = p;*g = v;*b = t;break;case 3:*r = p;*g = q;*b = v;break;case 4:*r = t;*g = p;*b = v;break;default:// case 5:*r = v;*g = p;*b = q;break;}
}
When programming in Java, use the rgbtohsb and hsbtorgb functions from the java. AWT. color class.
RGB to yiq & yiq to RGB
The yiq system is the color primary system adopted by National Television System Committee (NTSC) for color TV broadcasting. The yiq color solid is made by a linear transformation of the RGB cube. Its purpose is
To exploit certain characteristics of the human eye to maximize the utilization of a fixed bandwidth. the human visual system is more sensitive to changes in luminance than to changes in hue or saturation, and thus a wider bandwidth shocould be dedicated
Luminance than to color information.YIs similar to perceived luminance,IAndQCarry color information and some luminance information.YSignal usually has 4.2 MHz bandwidth in a 525
Line System. Originally,IAndQHad different bandwidths (1.5 and 0.6 MHz), but now they commonly have the same bandwidth of 1 MHz.
Here is the RGB-> yiq conversion:
[Y] [0.299 0.587 0.114] [R]
[I] = [0.596-0.275-0.321] [g]
[Q] [0.212-0.523 0.311] [B]
Here is the yiq-> RGB conversion:
[R] [1 1 0.956 0.621] [Y]
[G] = [1-0.272-0.647] [I]
[B] [1-1.105 1.702] [Q]
RGB to XYZ & XYZ to RGB
RGB values in a participant set of primaries can be transformed to and from cie xyz via a 3x3 Matrix Transform. These transforms involve tristimulus
Values, that is a set of three linear-light components that conform to the CIE color-matching functions. cie xyz is a special set of tristimulus values. in xyz, any color is represented as a set
Of positive values.
To transform fromXYZToRGB(With D65 white point), the Matrix Transform Used is [3]:
[R] [3.240479-1.537150-0.498535] [x]
[G] = [-0.969256 1.875992 0.041556] * [y]
[B] [0.055648-0.204043 1.057311] [Z].
The range for valid R, G, B values is [0, 1]. note, this matrix has negative coefficients. some XYZ color may be transformed to RGB values that are negative or greater than one. this means that not all
Visible colors can be produced using the RGB system.
The inverse transformation matrix is as follows:
[X] [0.412453 0.357580 0.180423] [r] **
[Y] = [0.212671 0.715160 0.072169] * [g]
[Z] [0.019334 0.119193 0.950227] [B].
** February 20,200 0-typo in this line of the matrix was corrected (0.189423 to 0.180423), thanks to Michal karczmarek, University of Toronto
XYZ to cie l * a * B * (cielab) & cielab to XYZ
CIE 1976 L * a * B * is based directly on CIE XYZ and is an attampt to linearize the perceptibility of color differences. the non-linear relations for L *, A *, and B * are intended to mimic the logarithmic response
The eye. Coloring information is referred to the color of the white point of the system, subscript n.
L * = 116*(Y/yn)1/3-16 for Y/YN> 0.008856
L * = 903.3*Y/YN otherwise
A * = 500*(F (x/XN)-f (y/yn ))
B * = 200*(F (y/yn)-f (z/Zn ))
Where f (t) = T1/3For T> 0.008856
F (t) = 7.787*T + 16/116 otherwise
Here XN, YN and Zn are the tristimulus values of the reference white.
The Reverse Transformation (for Y/YN> 0.008856) is
X = xn*(P + A */500) 3
Y = YN*P 3
Z = Zn*(P-B */200) 3
Where p = (L * + 16)/116
XYZ to cieluv & cieluv to XYZ
CIE 1976 L * u * (cieluv) is based directly on cie xyz and is another attampt to linearize the perceptibility of color differences. the non-linear relations for L *, u *, and V * are given below:
L * = 116*(Y/yn)1/3-16
U * = 13l **(U'-UN ')
V * = 13l **(V '-vn ')
The quantities UN 'and vn' refer to the reference white or the light source; for the 2 ° observer and illuminant C, UN' = 0.2009, vn '= 0.4610 [1].
Equations for U' and V' are given below:
U' = 4x/(x + 15y + 3z) = 4x/(-2x + 12y + 3)
V' = 9y/(x + 15y + 3z) = 9y/(-2x + 12y + 3 ).
The transformation from (U', V') to (x, y) is:
X = 27u'/(18u'-48v '+ 36)
Y = 12v '/(18u'-48v '+ 36 ).
The transformation from cieluv to XYZ is saved med as following:
U' = u/(13l *) + UN
V' = V/(13l *) + VN
Y = (L * + 16)/116) 3
X =-9yu '/(U'-4) V'-u'v ')
Z = (9y-15v 'Y-V' X)/3v'
Disclaimer:I (N. Schaller) received e-mail from Alexander Campo (acampo@laas.fr) stating that he felt the last three lines above shocould be
Y = (L x + 16)/116) ^ 3 * YN
And then simplify by noticing U 'V'-U' V '-4v' =-4v'
X = 9yu '/4v'
I have not verified this, but have added it for your purusal.
Link http://www.cs.rit.edu /~ NCS/color/t_convert.html