37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from PIL import Image
|
|
from operator import xor
|
|
|
|
input = "dungeons_portal_enc.png"
|
|
|
|
input_image = Image.open(input)
|
|
width, height = input_image.size
|
|
|
|
sample_size = 50
|
|
offset = 400
|
|
# output_image = Image.new(input_image.mode, (int(sample_size), int(sample_size)))
|
|
# for N in range(0,256):
|
|
# for x in range(offset, offset+sample_size):
|
|
# for y in range(offset, offset+sample_size):
|
|
# pixel = input_image.getpixel((x,y))
|
|
# if xor((x**3+y**7)%256, N)%256 == pixel:
|
|
# output_image.putpixel((x-offset,y-offset), 0)
|
|
# else:
|
|
# output_image.putpixel((x-offset,y-offset), 255)
|
|
|
|
# output_image.save(f"d_{N:04}.png")
|
|
|
|
#==>N semble valoir 7
|
|
|
|
N = 7
|
|
output_image = Image.new(input_image.mode, (int(width), int(height)))
|
|
|
|
for x in range(width):
|
|
for y in range(height):
|
|
pixel = input_image.getpixel((x,y))
|
|
if xor((x**3+y**7)%256, N)%256 == pixel:
|
|
output_image.putpixel((x,y), 0)
|
|
else:
|
|
output_image.putpixel((x,y), 255)
|
|
|
|
output_image.show()
|