from PIL import Image from PIL import ImageDraw img = Image.open('/Users/piv/Desktop/IMG_0818.png') # Create a new image of the cutout. blkimg = Image.new('1', (img.width, img.height) blkdraw = ImageDraw.Draw(blkimg) for i in range(1, img.width): for j in range(1, img.height): # getpixel returns tuple (r,g,b,a) pixel = img.getpixel((i, j)) if (pixel[0]/pixel[1]) > 1.05 and (pixel[0]/pixel[1]) < 4: