vil_colour_space.h
Go to the documentation of this file.
1 // This is core/vil/algo/vil_colour_space.h
2 #ifndef vil_colour_space_h_
3 #define vil_colour_space_h_
4 //:
5 // \file
6 // \brief Functions to convert between different colour spaces.
7 //
8 // Functions to convert between different colour spaces.
9 // See Foley and van Dam, "Computer Graphics, Principles and Practice".
10 //
11 // \author fsm
12 
13 //: Linear transformation from RGB to YIQ colour spaces
14 template <class T>
15 void vil_colour_space_RGB_to_YIQ(T const in[3], T out[3]);
16 
17 //: Linear transformation from YIQ to RGB colour spaces
18 template <class T>
19 void vil_colour_space_YIQ_to_RGB(T const in[3], T out[3]);
20 
21 
22 //: Transform from RGB to HSV colour spaces
23 // The input RGB values must lie in [0, L], for some positive L. Usually
24 // L=1 or 255.
25 //
26 // The output HSV values will lie in the ranges:
27 // H : [0, 360) (an angle, in bloody degrees)
28 // S : [0, 1]
29 // V : [0, L]
30 //
31 // [HSV is also known as HSB]
32 template <class T>
33 void vil_colour_space_RGB_to_HSV(T r, T g, T b, T *h, T *s, T *v);
34 
35 //: Transform from HSV to RGB colour space
36 //
37 // The input HSV values will lie in the ranges:
38 // H : [0, 360) (an angle, in bloody degrees)
39 // S : [0, 1]
40 // V : [0, 255]
41 //
42 // The output RGB values will lie in [0, 255]
43 //
44 // [HSV is also known as HSB]
45 template <class T>
46 void vil_colour_space_HSV_to_RGB(T h, T s, T v, T *r, T *g, T *b);
47 
48 
49 //: Linear transformation from RGB to YUV colour spaces
50 template <class T>
51 void vil_colour_space_RGB_to_YUV(T const in[3], T out[3]);
52 
53 //: Linear transformation from YUV to RGB colour spaces
54 template <class T>
55 void vil_colour_space_YUV_to_RGB(T const in[3], T out[3]);
56 
57 //: Transformation from analog RGB to analog YPbPr colour spaces
58 // The input and out value lie in the ranges:
59 // - R', G', B' in [0; 1]
60 // - Y' in [0; 1]
61 // - Pb in [-0.5; 0.5]
62 // - Pr in [-0.5; 0.5]
63 template <class T>
64 void vil_colour_space_RGB_to_YPbPr_601(T const RGB[3], T YPbPr[3]);
65 
66 //: Transformation from analog YPbPr to RGB colour spaces
67 // The input and out value lie in the ranges:
68 // - Y' in [0; 1]
69 // - Pb in [-0.5; 0.5]
70 // - Pr in [-0.5; 0.5]
71 // - R', G', B' in [0; 1]
72 template <class T>
73 void vil_colour_space_YPbPr_601_to_RGB(T const YPbPr[3], T RGB[3]);
74 
75 //: Transformation from 8 bit RGB to 8 bit YCbCr colour spaces
76 // The input and out value lie in the ranges:
77 // - R'd, G'd, B'd in {0, 1, 2, ..., 255}
78 // - Y' in {16, 17, ..., 235}
79 // with
80 // * footroom in {1, 2, ..., 15}
81 // * headroom in {236, 237, ..., 254}
82 // * sync. in {0, 255}
83 // - Cb, Cr in {16, 17, ..., 240}
84 void vil_colour_space_RGB_to_YCbCr_601(const unsigned char RGB[3], unsigned char YCbCr[3]);
85 
86 //: Transformation from 8 bit YCbCr to 8 bit RGB colour spaces
87 // The input and out value lie in the ranges:
88 // - Y' in {16, 17, ..., 235}
89 // with
90 // * footroom in {1, 2, ..., 15}
91 // * headroom in {236, 237, ..., 254}
92 // * sync. in {0, 255}
93 // - Cb, Cr in {16, 17, ..., 240}
94 // - R'd, G'd, B'd in {0, 1, 2, ..., 255}
95 void vil_colour_space_YCbCr_601_to_RGB(const unsigned char YCbCr[3], unsigned char RGB[3]);
96 
97 #endif // vil_colour_space_h_
void vil_colour_space_RGB_to_YCbCr_601(const unsigned char RGB[3], unsigned char YCbCr[3])
Transformation from 8 bit RGB to 8 bit YCbCr colour spaces.
void vil_colour_space_YIQ_to_RGB(T const in[3], T out[3])
Linear transformation from YIQ to RGB colour spaces.
void vil_colour_space_HSV_to_RGB(T h, T s, T v, T *r, T *g, T *b)
Transform from HSV to RGB colour space.
void vil_colour_space_RGB_to_YUV(T const in[3], T out[3])
Linear transformation from RGB to YUV colour spaces.
void vil_colour_space_YUV_to_RGB(T const in[3], T out[3])
Linear transformation from YUV to RGB colour spaces.
void vil_colour_space_RGB_to_YIQ(T const in[3], T out[3])
Linear transformation from RGB to YIQ colour spaces.
void vil_colour_space_RGB_to_HSV(T r, T g, T b, T *h, T *s, T *v)
Transform from RGB to HSV colour spaces.
void vil_colour_space_YCbCr_601_to_RGB(const unsigned char YCbCr[3], unsigned char RGB[3])
Transformation from 8 bit YCbCr to 8 bit RGB colour spaces.
void vil_colour_space_YPbPr_601_to_RGB(T const YPbPr[3], T RGB[3])
Transformation from analog YPbPr to RGB colour spaces.
void vil_colour_space_RGB_to_YPbPr_601(T const RGB[3], T YPbPr[3])
Transformation from analog RGB to analog YPbPr colour spaces.