Cody

Problem 42849. RGB to CMYK

Solution 2223839

Submitted on 20 Apr 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
RGB = [0,0,0]; CMYK = [0,0,0,1]; assert(isequal(rgb2cmyk(RGB),CMYK))

RGB = 0 0 0 K = 1 C = NaN M = NaN Y = NaN CMYK = NaN NaN NaN 1

Assertion failed.

2   Fail
RGB = [1,1,1]; CMYK = [0,0,0,0]; assert(isequal(rgb2cmyk(RGB),CMYK))

RGB = 0.0044 0.0044 0.0044 K = 0.9956 C = 0 M = 0 Y = 0 CMYK = 0 0 0 0.9956

Assertion failed.

3   Fail
RGB = [1,0,0]; CMYK = [0,1,1,0]; assert(isequal(rgb2cmyk(RGB),CMYK))

RGB = 0.0044 0 0 K = 0.9956 C = 0 M = 1 Y = 1 CMYK = 0 1.0000 1.0000 0.9956

Assertion failed.

4   Fail
RGB = [1,1,0]; CMYK = [0,0,1,0]; assert(isequal(rgb2cmyk(RGB),CMYK))

RGB = 0.0044 0.0044 0 K = 0.9956 C = 0 M = 0 Y = 1 CMYK = 0 0 1.0000 0.9956

Assertion failed.

5   Fail
RGB = [150,25,0]/255; CMYK = [0,5/6,1,7/17]; error = abs(rgb2cmyk(RGB)-CMYK); assert(all(error<1e-4))

RGB = 0.0026 0.0004 0 K = 0.9974 C = 0 M = 0.8333 Y = 1 CMYK = 0 0.8333 1.0000 0.9974

Assertion failed.