1

I am trying to recreate the green screen replacing for an assignment for school and I am having more trouble than anticipated with this. I have a list of the pixels in an image I am working with but they all unfortunately look like this (-9635059). How can I change these values into RGB values per pixel in order for me to continue working on it? So far I have had little luck with this:

def setup():
    global bgImage, fishImage, r, g, b, Pixels1, Pixels2
    size (800,500)
    fishImage=loadImage("https://i.ytimg.com/vi/TE6bcX66b_o/maxresdefault.jpg")
    bgImage=loadImage("http://naturewallpaperfree.com/space/nature-wallpaper-1920x1080-3146-644b3852.jpg")

    #load bgimage as the background and update the first list.
    image(bgImage,0,0,800,500)
    loadPixels()
    pixels1=pixels[0:]
    updatePixels()

    #load the fish image and then update the second list.
    image(fishImage,0,0,800,500)
    loadPixels()
    pixels2=pixels[0:]
    updatePixels()

    loadPixels()
    for i in pixels2:
        for x in range (width):
            for y in range (height):
                r=red(pixels[x*y])
                g=green(pixels[x*y])
                b=blue(pixels[x*y])
    updatePixels()

    img=createImage(800,500,RGB)
    loadPixels()
    for a in range (len(img.pixels)):
        for p in pixels2:
            if g>=150:
                a=pixels1
            else:
                a=pixels2
    updatePixels()
Northys
  • 1,305
  • 3
  • 16
  • 32
Tiegue
  • 11
  • 3

0 Answers0