Skip to content

Instantly share code, notes, and snippets.

@narcelio

narcelio/redgray.py

Created Nov 1, 2017
Embed
What would you like to do?
Viacoin second image decription
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# (c) Copyright 2017 by Narcelio Filho <narcelio@gmail.com>
from PIL import Image
from PIL import ImageOps
import numpy
im = Image.open('tpSCvHx.png')
bw = im.convert('L', dither=Image.NONE)
g = numpy.asarray(bw)
g = g < 80
m = Image.fromarray(g, '1')
m = ImageOps.invert(m.convert('L'))
m.show()
#m.save('/tmp/m.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment