Cody

Problem 2542. Convert a grayscale image into RGB colour format, preserving data type

Solution 498237

Submitted on 10 Sep 2014 by Matt Wolinsky
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   Pass
%% grayImage = [1 2 3; 4 5 6; 7 8 9]; rgbImage(:,:,1) = [1 2 3; 4 5 6; 7 8 9]; rgbImage(:,:,2) = [1 2 3; 4 5 6; 7 8 9]; rgbImage(:,:,3) = [1 2 3; 4 5 6; 7 8 9]; assert(isequal(gray2rgb(grayImage),rgbImage))

ans(:,:,1) = 1 2 3 4 5 6 7 8 9 ans(:,:,2) = 1 2 3 4 5 6 7 8 9 ans(:,:,3) = 1 2 3 4 5 6 7 8 9