Last active
May 13, 2020 17:23
-
-
Save robert-mcdermott/e483062375d0bc9641246fff1b2515ca to your computer and use it in GitHub Desktop.
separate-them.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
def main(): | |
images = [[] for p in range(num_people)] | |
im = Image.open(image) | |
im = im.convert("RGB") | |
size = im.size | |
data = list(im.getdata()) | |
for _ in range(int(len(data)/num_people)): | |
for p in range(num_people): | |
images[p].append(data.pop(0)) | |
for p in range(num_people): | |
ix = Image.new("RGB", (size[0] // num_people, size[1])) | |
ix.putdata(images[p]) | |
ix.show() | |
if __name__ == "__main__": | |
image = "separate-them.png" | |
num_people = 3 | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment