Ask Your Question

Revision history [back]

How to fix problem when creating image histogram

Hello, I'm trying to develop a function that calculates histograms for the colored images. When I run my program it says 'too many values to unpack (expected 2)'. What am I doing wrong here?

Below is my code

Collor_Channel =("r" , "g", "b")
PixelNum, Collor_Channel = im.shape
ImageHistogram = np.zeros(256)
    for i in range(PixelNum[0]):
          for j in range(PixelNum[1]):
               for x in range(PixelNum[2]):
                     totalvalue = im [j,i,x]
                            ImageHistogram[int(totalvalue)] += 1

                     return ImageHistogram