#from PIL import Image # #im = Image.open("1.png") # #for y in range(im.size[1]): # for x in range(im.size[0]): # pix = im.getpixel((x,y)) # print(pix) #from PIL import Image #im = Image.open("1.png") #count = 0 #for y in range(im.size[1]): # for x in range(im.size[0]): # pix = im.getpixel((x,y)) # if(pix[0] < 100 and pix[1] < 100 and pix[2] < 100): # count = count + 1 #print(count) #from PIL import Image #im = Image.open("1.png") #im2 = Image.new("RGB",im.size,255) #count = 0 #for y in range(im.size[1]): # for x in range(im.size[0]): # pix = im.getpixel((x,y)) # if(pix[0] < 100 and pix[1] < 100 and pix[2] < 100): # im2.putpixel((x,y),(255,255,255)) #im2.show() from PIL import Image im = Image.open("3.png") count = 0 for y in range(im.size[1]): for x in range(im.size[0]): pix = im.getpixel((x,y)) if(pix[0] < 50 and pix[1] < 50 and pix[2] < 50): im.putpixel((x,y),(255,255,255)) im.show()