Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- image = Image.open('image.png')
- rgb_im = image.convert('RGB')
- width, height = image.size
- output_image = Image.new('RGB', (width, height))
- for row in range(height):
- for col in range(width):
- r, g, b = rgb_im.getpixel((col, row))
- if (r < 128):
- p = 0
- else:
- p = 255
- output_image.putpixel((col, row), (p,p,p))
- output_image.save("bw.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement