2016-12-03 82 views
0

我正在替換此綠色屏幕的像素。 它只是不工作...問題代碼processing.py

def setup(): 
    size(852,480) 

def draw(): 
    image1 = loadImage("l.jpg") 
    image(image1,0,0,852,480) 
    loadPixels() 
    pixels1 = pixels[0:] 

    image2 = loadImage("r.jpg") 
    image(image2,0,0,852,480) 
    loadPixels() 
    pixels2 = pixels[0:] 

    for i in range(0,width*480): 
     r = red(pixels[i]) 
     g = green(pixels[i]) 
     b = blue(pixels[i]) 
     if g > 220: 
      pixels[i] = pixels1[i] 
     else: 
      pixels[i] = pixels2[i] 

enter image description here

回答