1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erica [24]
4 years ago
6

How to write a program converting RGB to CMYK in python

Computers and Technology
1 answer:
Arisa [49]4 years ago
5 0

rgb_scale = 255

cmyk_scale = 100

def rgb_to_cmyk(r,g,b):

if (r == 0) and (g == 0) and (b == 0):

return 0, 0, 0, cmyk_scale

# rgb [0,255] -> cmy [0,1]

c = 1 - r / float(rgb_scale)

m = 1 - g / float(rgb_scale)

y = 1 - b / float(rgb_scale)

min_cmy = min(c, m, y)

c = (c - min_cmy)

m = (m - min_cmy)

y = (y - min_cmy)

k = min_cmy

return c*cmyk_scale, m*cmyk_scale, y*cmyk_scale, k*cmyk_scale

def cmyk_to_rgb(c,m,y,k):

r = rgb_scale*(1.0-(c+k)/float(cmyk_scale))

g = rgb_scale*(1.0-(m+k)/float(cmyk_scale))

b = rgb_scale*(1.0-(y+k)/float(cmyk_scale))

return r,g,b

You might be interested in
A debate about city schools are more better than village schools​
Vladimir [108]
No it is not because village school is the traditional education
6 0
3 years ago
What would you use to see what network adapters are installed in your windows computer?
Lesechka [4]
I wouldn't see anything, because my computer does not use any network adaptors.
6 0
3 years ago
Look at the following Python code:
aliya0001 [1]

Ump will be assigned to word2

word1[0:3] gets all of the letters from index 0 to index 3 exclusive (that means index 3 is not included)

4 0
3 years ago
Which icon is greater in file size? (Show your working)
nadya68 [22]

Answer:

the 256 color icon would be greater in file size.

Explanation:

regardless of how many pixels are in the image, file A has 256 colors meaning the computer has to individually load each one of those colors. it'll probably use a lot of ink if you decide to print it, too.

5 0
3 years ago
Competition between individuals in a population is due to (2 points)
madam [21]
Competition between individuals in a population is due to (2 points)
limited resources
5 0
4 years ago
Other questions:
  • 8. Seleccione la respuesta correcta de acuerdo con las opciones que aparece a continuación:
    11·1 answer
  • What type of storage system is a hard drive on a computer?<br> Need HELP fast, please.
    9·2 answers
  • The body element is where you provide browsers with information about the document
    12·1 answer
  • Welcome back to school people!
    15·2 answers
  • What is one reason that writing effective messages is so important
    11·2 answers
  • Who tryna play fortnite?
    5·2 answers
  • Scrie un program care citind varstele a 2 copii afiseaza care dintre ei este cel mai mare si cu cat. Exemplu: Pentru varstele 5
    9·1 answer
  • What is a good range for CPU usage to be considered running well?
    15·1 answer
  • How much data can a flash drive store?​
    13·2 answers
  • The current in a resistor is 5.0 A, and its power is 60 W. What is the voltage?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!