All problems
Color Histogram RGB
Problem
Compute per-channel histograms of an RGB image with a fixed number of bins.
The bin index for a value v is v * bins // 256. Return [red_hist, green_hist, blue_hist], each a list of bins counts.
Test cases
case 1
in: [[[[0,255,128],[64,64,255]]],4]
expected: [[1,1,0,0],[0,1,0,1],[0,0,1,1]]
case 2
in: [[[[0,0,0],[255,255,255]]],2]
expected: [[1,1],[1,1],[1,1]]
case 3
in: [[[[10,20,30],[250,240,230]]],4]
expected: [[1,0,0,1],[1,0,0,1],[1,0,0,1]]
Starter codePython
def rgb_histogram(image, bins):
# Your code here
pass3 test cases · run your code against them in the editor