All problems
Merge RGB Channels
Problem
Merge three single-channel images into one RGB image.
Given 2D lists r, g and b of the same shape, return a 2D list where each pixel is [r[i][j], g[i][j], b[i][j]]. Empty inputs return [].
Hint
Zip the three grids position by position into pixel triples.
Test cases
case 1
in: [[[1,2],[3,4]],[[5,6],[7,8]],[[9,10],[11,12]]]
expected: [[[1,5,9],[2,6,10]],[[3,7,11],[4,8,12]]]
case 2
in: [[[10]],[[20]],[[30]]]
expected: [[[10,20,30]]]
case 3
in: [[],[],[]]
expected: []
Starter codePython
def merge_channels(r, g, b):
# Your code here
pass3 test cases · run your code against them in the editor