-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarhol_filter.py
More file actions
35 lines (29 loc) · 907 Bytes
/
warhol_filter.py
File metadata and controls
35 lines (29 loc) · 907 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
27
28
29
30
31
32
33
34
35
"""
This program generates the Warhol effect based on the original image.
"""
from simpleimage import SimpleImage
N_ROWS = 2
N_COLS = 3
PATCH_SIZE = 222
WIDTH = N_COLS * PATCH_SIZE
HEIGHT = N_ROWS * PATCH_SIZE
PATCH_NAME = 'images/simba-sq.jpg'
def main():
image = SimpleImage.blank(WIDTH, HEIGHT)
for a in range(N_ROWS):
for i in range(N_COLS):
for y in range(PATCH_SIZE):
for x in range(PATCH_SIZE):
patch = make_recolored_patch()
pixel = patch.get_pixel(x, y)
image.set_pixel(x + (i*PATCH_SIZE), y + (a*PATCH_SIZE), pixel)
image.show()
def make_recolored_patch():
patch = SimpleImage(PATCH_NAME)
for pixel in patch:
pixel.red = pixel.red * 1.5
pixel.green = pixel.green * 0
pixel.blue = pixel.blue * 1.5
return patch
if __name__ == '__main__':
main()