Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- Created on Wed Dec 13 17:53:00 2017
- @author: dad
- """
- from PIL import Image
- from pathlib import Path
- import time
- PathToFile = '/Users/dad/Desktop/Fruit.jpg'
- picturefile = Path(PathToFile)
- if picturefile.exists():
- #print('file exists')
- myImage = Image.open(PathToFile)
- myImage.getbands()
- #myImage.show()
- pix = myImage.load() #Get the RGBA Value of the a pixel of an image
- start = time.time()
- for x in range(myImage.width - 1):
- for y in range(myImage.height - 1):
- if (pix[x, y][0] > 120) & (pix[x, y][1] < 70) & (pix[x, y][2] < 60):
- pix[x, y] = pix[x, y]
- #print(pix[x, y])
- else:
- pix[x, y] = (255,255,255)
- stop = time.time()
- myImage.show()
- print(stop - start)
Add Comment
Please, Sign In to add comment