The colorsys.rgb_to_yiq(r, g, b)
function converts RGB (Red Green Blue) coordinates to YIQ (Luminance (Y) In-phase Quadrature) coordinates.
The colorsys
module stores the definition of rgb_to_yiq()
function. The colorsys
module can be imported using the following code:
import colorsys
colorsys.rgb_to_yiq(r, g, b)
r
, g
, and b
can have any value between 0 and 1 inclusive.
The following code snippet demonstrates the use of rgb_to_yiq()
:
import colorsys if __name__ == '__main__': r = 53 g = 122 b = 99 y, i, q = colorsys.rgb_to_yiq(r, g, b) print('RGB:-') print('r: ' + str(r) + '\ng: ' + str(g) + '\nb: ' + str(b)) print('\nYIQ:-') print('y: ' + str(y) + '\ni: ' + str(i) + '\nq: ' + str(q))
The rgb_to_yiq()
function in line 8 converts the r
, g
, and b
values that are created in lines 4-7 to y
, i
and q
values.
RELATED TAGS
CONTRIBUTOR
View all Courses