Created
April 5, 2022 20:12
-
-
Save rmmh/5ce891e9429232e1b53197716985ee69 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# grab data from https://place.thatguyalex.com/ | |
import glob | |
import numpy | |
import PIL.Image | |
import scipy.stats | |
EXPECTED_PALETTE = None | |
END = 1649112396 | |
ims = [] | |
qs = [] | |
for n in range(4): | |
si = [] | |
fs = [] | |
for f in sorted(glob.glob(f"images_quadro/{n}/*-164911*")): | |
if END - 3600 <= int(f.split('.')[0].split('-')[-1]) <= END: | |
fs.append(f) | |
for f in fs: | |
i = PIL.Image.open(f) | |
if not EXPECTED_PALETTE: | |
EXPECTED_PALETTE = i.palette.getdata() | |
assert i.palette.getdata() == EXPECTED_PALETTE | |
si.append(i) | |
print(n, len(fs)) | |
quadrant = numpy.dstack([numpy.array(i) for i in si]) | |
mode = scipy.stats.mode(quadrant, axis=2).mode | |
mode = mode.transpose()[0].transpose() | |
im = PIL.Image.fromarray(mode) | |
im.putpalette(EXPECTED_PALETTE[1]) | |
im.save(f"Q{n}.png") | |
qs.append(im) | |
ims.extend(fs) | |
print(len(ims)) | |
out = PIL.Image.new('P', (2000, 2000)) | |
out.putpalette(EXPECTED_PALETTE[1]) | |
for n, q in enumerate(qs): | |
out.paste(q, (n % 2 * 1000, n // 2 * 1000)) | |
out.save('averaged.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment