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]
3 years ago
6

How to write a program converting RGB to CMYK in python

Computers and Technology
1 answer:
Arisa [49]3 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
When you make a cell phone call, which type of electromagnetic wave is most likely transmitting the signal?
Olegator [25]
They use Radio waves 
6 0
2 years ago
Which type of information could be displayed using this line graph?
ollegr [7]

Answer:

The first one I'm sorry if I'm wrong

3 0
2 years ago
Read 2 more answers
Describe how serial data access finds data
jeyben [28]

Answer:

Serial data access will go through all the data by order until the target data is reached

Explanation:

This is opposite of direct data access which immediately finds the desired

data

4 0
3 years ago
Read 2 more answers
Which of the following is the best description of the [Drive for] block?
Ede4ka [16]
The answer is C to this question
6 0
2 years ago
What country is associated with the tor relay using the ip address 104. 244. 74. 97?.
Lelu [443]

Answer:

104.28.63.45 is an IP address located in Santos, Sao Paulo.

Explanation:

3 0
2 years ago
Other questions:
  • Define a function below called average_strings. The function takes one argument: a list of strings. Complete the function so tha
    11·1 answer
  • Help what is a computer made from (computer class question)!!
    9·1 answer
  • What are the differences in LAN and WAN and how they are used to Increase Cybersecurity
    7·1 answer
  • Assume that the array arr has been defined and initialized with the values {4, 2, 5, 3, 1}. What are the values in the array arr
    15·1 answer
  • Exampels of semantic tags ?​
    7·1 answer
  • This is pixlr
    6·1 answer
  • What was the first portable computer called and who made it?
    9·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    11·1 answer
  • true or false hardware diagnostics let you run a quick check of system hardware and can verify that most systems components are
    5·1 answer
  • How does the use of blocking affect the external sorting algorithm, and how does it change the cost formula
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!