This is the part of my code that gives the problem. It is supposed to count the amount of green pixels in a picture:
img = Image.open('path.tif')
BLACK_MIN = np.array([0, 20, 20], np.uint8)
BLACK_MAX = np.array([120, 255, 255], np.uint8)
imgg = cv2.imread(img, 1)
dst = cv2.inRange(imgg, BLACK_MIN, BLACK_MAX)
no_black = cv2.countNonZero(dst)
print('The number of black pixels is: ' + str(no_black))