Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
python3

What is colorsys.yiq_to_rgb(y, i, q) in Python?

Syed Muhammad Ali Mustafa

The colorsys.yiq_to_rgb(r, g, b) function converts YIQLuminance (Y) In-phase Quadrature coordinates to RGBRed Green Blue coordinates. The yiq color scale is a recoding of the rgb color scale generally used for the US TV broadcast.

Declaration

The colorsys module stores the definition of the yiq_to_rgb() function. We can import the colorsys module using the following code:

import colorsys

colorsys.yiq_to_rgb(y, i, q)

y can have any value between 0 and 1 inclusive. i and q can have any value between -1 and 1 inclusive.

Code

The following code snippet demonstrates the use of yiq_to_rgb():

import colorsys

if __name__ == '__main__':
  y = 0.61
  i = -0.03
  q = -0.11

  r, g, b = colorsys.yiq_to_rgb(y, i, q)

  print('YIQ:-')
  print('y: ' + str(y) + '\ni: ' + str(i) + '\nq: ' + str(q))
  print('\nRGB:-')
  print('r: ' + str(r) + '\ng: ' + str(g) + '\nb: ' + str(b))

RELATED TAGS

python
python3

CONTRIBUTOR

Syed Muhammad Ali Mustafa
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring