Nimish Bansal Nimish Bansal - 23 days ago 6
Python Question

how can i get no of red pixels and no of black pixels in PIL image

from PIL import ImageGrab
pil_img=ImageGrab.grab([0,0,1000,1000])


Now I want to get no of red pixels and no of black pixels in two separate variables.So how should I proceed on pil_imgThe image look likes this

J H J H
Answer Source

Use pil_image.getpixel(x, y).