I am working on image processing, I want to know if this code will split the color image into different channels and give me an average value. Because when I tried to give it the image that I am reading, it gives me blue, green, red values, as well as the average value. When I try to add it to the list and try to print it, then the list contains only zeros.
This is my code:
b, g, r = cv2.split(re_img1)
ttl = re_img1.size
B = sum(b) / ttl
G = sum(g) / ttl
R = sum(r) / ttl
B_mean1.append(B)
G_mean1.append(G)
R_mean1.append(R)
re_img1is the resized image (i.e. 256x256). The image can be any. And I use the same code in 2 different functions, and I ran into the same problem.
Any suggestions are welcome! Thanks in advance!
source
share