Skip to content

Instantly share code, notes, and snippets.

@HarveyBrezinaConniffe
Created December 23, 2019 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarveyBrezinaConniffe/4136b3847215360a4a81ad86a12b430e to your computer and use it in GitHub Desktop.
Save HarveyBrezinaConniffe/4136b3847215360a4a81ad86a12b430e to your computer and use it in GitHub Desktop.
import numpy as np
import numpy.ma as ma
import sys
from PIL import Image
np.set_printoptions(threshold=sys.maxsize, linewidth=999)
x = 25
y = 6
rawimg = np.array(list(map(int, list(str(input())))))
rawimg = np.reshape(rawimg, (-1, x))
layers = np.split(rawimg, rawimg.shape[0]/y, axis=0)
end = np.zeros(layers[0].shape)
mask = np.zeros(layers[0].shape).astype(bool)
for clayer in layers:
clayer = ma.array(clayer, mask=mask)
end += clayer==1
mask = ma.mask_or(mask, (clayer!=2))
im = Image.fromarray(np.uint8(end)*255)
im.save("IMG.jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment