codeblock

2016年3月30日 星期三

Python Challenge level 11

http://www.pythonchallenge.com/pc/return/5808.html (login:huge/file)

- No much tips, just "odd even" in the title and a very vague picture. Seems like this picture is processed for a certain purpose.
- Divide the picture into 4 parts according to the pixel coordinate. (00, 01, 10, 11)


from PIL import Image, ImageDraw
cave = Image.open("cave.jpg")
width, height = cave.size
pixels = cave.load()

result = Image.new(mode="RGB", size=(width, height), color=0)
pixels_result = result.load()

for i in range(width):
 for j in range(height):
  if i%2==0 and j%2==0:
   pixels_result[i/2, j/2] = pixels[i, j]
  elif i%2==0 and j%2==1:
   pixels_result[i/2+width/2, j/2] = pixels[i, j]
  elif i%2==1 and j%2==0:
   pixels_result[i/2, j/2+height/2] = pixels[i, j]
  elif i%2==1 and j%2==1:
   pixels_result[i/2+width/2, j/2+height/2] = pixels[i, j]
result.save("result.jpg")
- The result shows four pictures like:


















- The answer is hidden in the first and forth picture: "evil"

沒有留言:

張貼留言