Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- from PIL import Image, ImageDraw #Подключим необходимые библиотеки.
- def is_black(pixel):
- ok = 1
- ok &= pixel[0] < 20
- ok &= pixel[1] < 20
- ok &= pixel[2] < 20
- return ok
- images = ['car.jpg', 'cat.jpg', 'dog.jpg', 'girl.jpg']
- image, draw, h, w, pix = [], [], [], [], []
- for i in images:
- _image = Image.open(i)
- image.append(_image)
- draw.append(ImageDraw.Draw(_image))
- w.append(_image.size[0])
- h.append(_image.size[1])
- pix.append(_image.load())
- w, h = 4000, 2000
- for i in range(1, 4):
- for x in range(w):
- for y in range(h):
- pixel = pix[0][x, y]
- second = pix[i][x, y]
- new_point = []
- is1, is2 = is_black(pixel), is_black(second)
- if (is1 and is2):
- new_point = (255, 255, 255)
- else: new_point = (0, 0, 0)
- draw[0].point((x, y), new_point)
- #draw.point((i, j), (a, b, c))
- image[0].save("ansand.jpg", "JPEG")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement