2 nouveaux défis
This commit is contained in:
36
Les écailles du dragon....py
Normal file
36
Les écailles du dragon....py
Normal file
@@ -0,0 +1,36 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user