Cody

# Problem 1368. Create an 8-color version of an image

Solution 3188936

Submitted on 13 Oct 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
A = randi([51 255],[600 800 3]); t = [0 25 50]; B = warholer(A,t); assert(all(B(:)==255))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test1 (line 3) B = warholer(A,t);

2   Fail
A = randi(100,[800 600 3]); t = [100 255 100]; B = warholer(A,t); assert(all(B(:)==0))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test2 (line 3) B = warholer(A,t);

3   Fail
A = zeros(200,200,3); t = randi(255,1,3); B = warholer(A,t); assert(all(B(:)==0))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test3 (line 3) B = warholer(A,t);

4   Fail
A = 255*ones(100,100,3); t = randi(254,1,3); B = warholer(A,t); assert(all(B(:)==255))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test4 (line 3) B = warholer(A,t);

5   Fail
A(:,:,1) = randi([0 120],[480 320]); A(:,:,2) = randi([80 200],[480 320]); A(:,:,3) = randi([160 240],[480 320]); t = [150 50 150]; B = warholer(A,t); assert(all(all(B(:,:,1)==0))) assert(all(all(B(:,:,2)==255))) assert(all(all(B(:,:,3)==255)))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test5 (line 5) B = warholer(A,t);

6   Fail
A(:,:,1) = randi([0 100],[480 320]); A(:,:,2) = randi([80 180],[480 320]); A(:,:,3) = randi([100 240],[480 320]); t = [180 60 250]; B = warholer(A,t); assert(all(all(B(:,:,1)==0))) assert(all(all(B(:,:,2)==255))) assert(all(all(B(:,:,3)==0)))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test6 (line 5) B = warholer(A,t);

7   Fail
A(:,:,1) = magic(5)*10; A(:,:,2) = spiral(5)*10; A(:,:,3) = toeplitz(1:5)*50; t = [159 99 149]; B_correct(:,:,1) = [255 255 0 0 0; 255 0 0 0 255; 0 0 0 255 255; 0 0 255 255 0; 0 255 255 0 0]; B_correct(:,:,2) = [255 255 255 255 255; 255 0 0 0 255; 255 0 0 0 255; 255 0 0 0 255; 255 255 255 255 255]; B_correct(:,:,3) = [0 0 255 255 255; 0 0 0 255 255; 255 0 0 0 255; 255 255 0 0 0; 255 255 255 0 0]; assert(isequal(warholer(A,t),B_correct))

Unrecognized function or variable 'map'. Error in warholer (line 2) [Y,newmap] = imapprox(A,map,t); Error in Test7 (line 20) assert(isequal(warholer(A,t),B_correct))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!