Guest User

Untitled

a guest
Dec 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Wed Dec 13 17:53:00 2017
  5.  
  6. @author: dad
  7. """
  8.  
  9. from PIL import Image
  10. from pathlib import Path
  11. import time
  12.  
  13. PathToFile = '/Users/dad/Desktop/Fruit.jpg'
  14. picturefile = Path(PathToFile)
  15. if picturefile.exists():
  16. #print('file exists')
  17. myImage = Image.open(PathToFile)
  18. myImage.getbands()
  19. #myImage.show()
  20. pix = myImage.load() #Get the RGBA Value of the a pixel of an image
  21.  
  22. start = time.time()
  23. for x in range(myImage.width - 1):
  24. for y in range(myImage.height - 1):
  25. if (pix[x, y][0] > 120) & (pix[x, y][1] < 70) & (pix[x, y][2] < 60):
  26. pix[x, y] = pix[x, y]
  27. #print(pix[x, y])
  28. else:
  29. pix[x, y] = (255,255,255)
  30. stop = time.time()
  31.  
  32. myImage.show()
  33. print(stop - start)
Add Comment
Please, Sign In to add comment