This commit is contained in:
Roman Hergenreder 2018-12-09 10:36:48 +01:00
parent 5a963c7654
commit 89d6321015
7 changed files with 40 additions and 1 deletions

@ -74,7 +74,7 @@ if snail.count("0") != bits.count("0") or snail.count("1") != bits.count("1"):
print("Bits do not match") print("Bits do not match")
exit() exit()
im = Image.new('RGB', im.size) im = Image.new('RGB', im.black)
pix = im.load() pix = im.load()
for tileY in range(0, numTiles): for tileY in range(0, numTiles):

38
Day 9/decode.py Executable file

@ -0,0 +1,38 @@
#!/usr/bin/python
from PIL import Image
imageOriginal = Image.open("medium_64_original.png")
imageFake = Image.open("medium-64_decompressed.png")
pixOriginal = imageOriginal.load()
pixFake = imageFake.load()
if imageOriginal.size != imageFake.size:
print("Images differ in Size")
exit()
diffs = []
Size = imageOriginal.size
for y in range(Size[0]):
for x in range(Size[1]):
if pixOriginal[x,y] != pixFake[x,y]:
diffs.append([x,y])
x0 = min([diff[0] for diff in diffs])
x1 = max([diff[0] for diff in diffs])
y0 = min([diff[1] for diff in diffs])
y1 = max([diff[1] for diff in diffs])
imageNew = Image.new('RGB', Size, "white")
pix = imageNew.load()
for x in range(x0, x1+1):
for y in range(y0, y1+1):
pix[x,y] = (0,0,0,255)
for diff in diffs:
pix[diff[0], diff[1]] = (255,255,255,255)
imageNew.save("decoded.png")

BIN
Day 9/decoded.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

BIN
Day 9/medium-64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

@ -0,0 +1 @@
#!/usr/bin/python