I'm new to python and any help would be greatly appreciated.
What I'm trying to do from this image is to count the number of black pixels (0,0,0) and the consecutive values i.e (1,1,1), (2,2,2), (3,3,3) all up to (255,255,255). So the code would print out answers such as:
(0,0,0) = 10 pixels
(1,1,1) = 5 pixels
(2,2,2) = 8 pixels
etc.
This is a code I found online to find the blue pixels but I don't want to set a upper and lower boundary. I'm completely confused on how to do this please help!
import cv2
import numpy as np
img = cv2.imread("multi.png")
BLUE_MIN = np.array([0, 0, 200], np.uint8)
BLUE_MAX = np.array([50, 50, 255], np.uint8)
dst = cv2.inRange(img, BLUE_MIN, BLUE_MAX)
no_blue = cv2.countNonZero(dst)
print('The number of blue pixels is: ' + str(no_blue))
cv2.namedWindow("opencv")
cv2.imshow("opencv",img)
cv2.waitKey(0)