Question
CMYK to RGB color matching. Write a program CMYKtoRGB that reads in four command line inputs C, M, Y, and K between 0 and 1,
CMYK to RGB color matching. Write a program CMYKtoRGB that reads in four command line inputs C, M, Y, and K between 0 and 1, and prints the corresponding RGB parameters. Devise the appropriate formula by "inverting" the RGB to CMYK conversion formula. This is for Java. Using Dr.Java. Here is my code for RGB to CMYK and it wants me to invert the formula for CMYK to RGB.
public class Ex_1_2_32 { public static void main(String[] args) { double r = Double.parseDouble(args[0]); double g = Double.parseDouble(args[1]); double b = Double.parseDouble(args[2]); double w = Math.max(r / 255, Math.max(g / 255, b / 255)); double c = (w - (r / 255)) / w; double m = (w - (g / 255)) / w; double y = (w - (b / 255)) / w; double k = 1 - w; System.out.println("C = " + c); System.out.println("M = " + m); System.out.println("Y = " + y); System.out.println("K = " + k); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started