1mlib_ImageColorRGB2HSV(3MLImBe)diaLib Library Functiomnlsib_ImageColorRGB2HSV(3MLIB)
2
3
4
6 mlib_ImageColorRGB2HSV - RGB to HSV color conversion
7
9 cc [ flag... ] file... -lmlib [ library... ]
10 #include <mlib.h>
11
12 mlib_status mlib_ImageColorRGB2HSV(mlib_image *dst, const mlib_image *src);
13
14
16 The mlib_ImageColorRGB2HSV() function performs a conversion from
17 red/green/blue to hue/saturation/value. The source and destination
18 images must be three-channel images.
19
20
21 It uses the following equations:
22
23 V = max(R, G, B)
24 Vmin = min(R, G, B)
25
26 S = (V - Vmin)/V
27
28 H = (5.0 + (V - B)/(V - Vmin))/6 if R = V and G = Vmin
29 H = (1.0 - (V - G)/(V - Vmin))/6 if R = V and B = Vmin
30 H = (1.0 + (V - R)/(V - Vmin))/6 if G = V and B = Vmin
31 H = (3.0 - (V - B)/(V - Vmin))/6 if G = V and R = Vmin
32 H = (3.0 + (V - G)/(V - Vmin))/6 if B = V and R = Vmin
33 H = (5.0 - (V - R)/(V - Vmin))/6 if B = V and G = Vmin
34 H = 0.0 if R = G = B
35
36
37
38 where 0 ≤ R, G, B, V, Vmin, S ≤ 1 and 0 ≤ H < 1.
39
40
41 Assuming a pixel in the source image is (r, g, b) and its corresponding
42 pixel in the destination image is (h, s, v), then for MLIB_BYTE images,
43 the following applies:
44
45 R = r/255
46 G = g/255
47 B = b/255
48 h = H*256
49 s = S*255
50 v = V*255
51
52
53
54 for MLIB_SHORT images, the following applies:
55
56 R = (r + 32768)/65535
57 G = (g + 32768)/65535
58 B = (b + 32768)/65535
59 h = H*65536 - 32768
60 s = S*65535 - 32768
61 v = V*65535 - 32768
62
63
64
65 for MLIB_USHORT images, the following applies:
66
67 R = r/65535
68 G = g/65535
69 B = b/65535
70 h = H*65536
71 s = S*65535
72 v = V*65535
73
74
75
76 and for MLIB_INT images, the following applies:
77
78 R = (r + 2147483648)/4294967295
79 G = (g + 2147483648)/4294967295
80 B = (b + 2147483648)/4294967295
81 h = H*4294967296 - 2147483648
82 s = S*4294967295 - 2147483648
83 v = V*4294967295 - 2147483648
84
85
87 The function takes the following arguments:
88
89 dst Pointer to destination image.
90
91
92 src Pointer to source image.
93
94
96 The function returns MLIB_SUCCESS if successful. Otherwise it returns
97 MLIB_FAILURE.
98
100 See attributes(5) for descriptions of the following attributes:
101
102
103
104
105 ┌─────────────────────────────┬─────────────────────────────┐
106 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
107 ├─────────────────────────────┼─────────────────────────────┤
108 │Interface Stability │Committed │
109 ├─────────────────────────────┼─────────────────────────────┤
110 │MT-Level │MT-Safe │
111 └─────────────────────────────┴─────────────────────────────┘
112
114 mlib_ImageColorHSV2RGB(3MLIB), mlib_ImageColorHSV2RGB_Fp(3MLIB),
115 mlib_ImageColorRGB2HSV_Fp(3MLIB), attributes(5)
116
117
118
119SunOS 5.11 2 Mar 2007 mlib_ImageColorRGB2HSV(3MLIB)