Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. obamaImage = None
  2. beachImage = None
  3.  
  4. def setup():
  5.     global backImage
  6.     size(500,500)
  7.     backImage = loadImage("beach.jpg")
  8.     image(backImage,0 ,0 ,500 ,500)
  9.     loadPixels()
  10.     pixelsBack = pixels[0:]
  11.    
  12.     global frontImage
  13.     size (500,500)
  14.     frontImage = loadImage("obama.jpg")
  15.     image(frontImage,0,0,500,500)
  16.     loadPixels()
  17.     pixelsFront = pixels[0:]
  18.  
  19.     for x in range(0, width):
  20.         for y in range(0, height):
  21.             i = x + width*y
  22.             if (green(pixelsFront[i]) >= 150 and red(pixelsFront[i]) <= 80 and blue(pixelsFront[i]) <= 80) or \ #this is one case where there is high green and high red and blue
  23.                (green(pixelsFront[i]) >= 100 and red(pixelsFront[i]) <= 20 and blue(pixelsFront[i]) <= 20) : #this is another case where there is lower green, but also low red and low blue
  24.                     pixels[i] = pixelsBack[i] #mods the current selected pixels from pixelsFront when conditions are met, to be from pixelsBack
  25.                
  26.     updatePixels()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement