Created
January 27, 2019 09:44
-
-
Save jilm/ab62a3009b46de78546ed8aa447ff8c5 to your computer and use it in GitHub Desktop.
A script to show a picture with grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PIL.Image | |
import sys | |
filename = sys.argv[1] | |
im = PIL.Image.open(filename) | |
im = im.convert('L') | |
w, h = im.size | |
gs = min(w, h) // 12 | |
for r in range(h // gs): | |
for c in range(w): | |
coor = (c, r * gs) | |
im.putpixel(coor, 255-im.getpixel(coor)) | |
for r in range(h): | |
for c in range(w // gs): | |
coor = (c * gs, r) | |
im.putpixel(coor, 255-im.getpixel(coor)) | |
im.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment