I am looking for an easy way to count the number of the green pixels in the image below, where the original image is the same but the green pixels are black.
I tried it with numpy.diff()
, but then I am counting some pixels twice. I thought about numpy.gradient()
– but here I am not sure if it is the right tool.
I know there have to be many solutions to this problem, but I don't know how to google for it. I am looking for a solution in python.
To make it clearer, I have only one image (only black and white pixels). The image with the green pixel is just for illustration.