All problems
Split RGB Channels
Problem
Split an RGB image into its three color channels.
The input is a 2D list of [r, g, b] pixels. Return a list of three 2D lists [red, green, blue], each holding the corresponding channel values. An empty image returns [[], [], []].
Hint
Build three grids by picking index 0, 1 and 2 from every pixel.
Test cases
case 1
in: [[[[1,2,3],[4,5,6]]]]
expected: [[[1,4]],[[2,5]],[[3,6]]]
case 2
in: [[[[10,20,30]]]]
expected: [[[10]],[[20]],[[30]]]
case 3
in: [[]]
expected: [[],[],[]]
Starter codePython
def split_channels(image):
# Your code here
pass3 test cases · run your code against them in the editor