Hello Im trying to calculate pixles of each R/G/B and create histogram of some picture, histogram is looking nice but I cannot calculate pixles of each colour. It says the same amount for each colour which I doubt is correct.
Here is my code, Im fairly new to it and Im run out of ideas
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
img = cv.imread('photo.jpg')
color = ('b','g','r')
qtdBlue = 0
qtdGreen = 0
qtdRed = 0
totalPixels = 0
for i,col in enumerate(color):
histr = cv.calcHist([img],[i],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0, 256])
totalPixels+=sum(histr)
if i==0:
qtdBlue = sum(histr)
elif i==1:
qtdGreen = sum(histr)
elif i==2:
qtdRed = sum(histr)
print("Red Quantity")
print(qtdRed)
print("Blue Quantity")
print(qtdBlue)
print("Green Quantity")
print(qtdGreen)
plt.show()




intensitiesthey will always have the same value.