-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11_5808.py
More file actions
26 lines (20 loc) · 731 Bytes
/
11_5808.py
File metadata and controls
26 lines (20 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# http://www.pythonchallenge.com/pc/return/5808.html
import Image
Img=Image.open('11_cave.jpg')
OddImage=EvenImage=Image.new(Img.mode, (320, 240))
for x in range(640):
for y in range(480):
pixel=Img.getpixel((x, y))
if x%2==0 and y%2==0:
OddImage.putpixel((x/2, y/2), pixel)
elif x%2==1 and y%2==0:
EvenImage.putpixel(((x-1)/2, y/2), pixel)
elif x%2==0 and y%2==1:
EvenImage.putpixel((x/2, (y-1)/2), pixel)
elif x%2==1 and y%2==1:
OddImage.putpixel(((x-1)/2, (y-1)/2), pixel)
OddImage.save('11_Odd.jpg')
EvenImage.save('11_Even.jpg')
# http://www.pythonchallenge.com/pc/return/evil.html