Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I was wondering if you\'d be able to help me with the python\'s processing progr

ID: 3571945 • Letter: I

Question

I was wondering if you'd be able to help me with the python's processing programming/processing.py (http://py.processing.org/reference/). I'm in an undergraduate Creative Computer course and some of the questions on my assignment about Green Screen is confusing me. Here's a problem I need help with:

Filmmakers often photograph their subjects in front of a plain background, often blue or green in colour, and later replace the plain background with a more exotic background. In this exercise, you will do the same using Processing. This is simpler than it sounds. You simply need to compare each of the photos pixel by pixel and choose which of the two pixels should be included in the combined picture. Part 1: Green Screen Find a picture on the internet that has been taken using a green or blue screen (google "green screen" using Google Images). (Or better yet, take one of yourself in front of a plain green or blue background -- this is easier said than done -- you need to get the background colour as even as possible which can prove to be challenging). Create a new picture by combining the green screen picture with a picture depicting some nice scenery (a field of flowers? a desert? a stadium? -- anything (appropriate) that you find appealing). Here is an example that I shamelessly stole (without permission) from the internet. The left image is the green screen image. The other two images are a combination of the green screen image and other pictures. Notes: Your two pictures should be the same size so that you can simply cycle through all the pixels of each picture. You can size the images using something like Paint. You will need to determine what constitutes the "blue" or "green" background. You cannot assume each pixel is exactly the same colour. You will need to figure out a formula that you can use to determine whether the colour of a pixel belongs to the blue/green background or the subject. In order to have 2 "pixels" lists open at once, you will need to open one image file, load the pixels then make a copy of the pixels list (pixels1 = pixels[0:]). You can then open the second image and load the pixels for that image into the built-in variable "pixels". Save your resulting picture as a .jpg using the save() command. The parameter to the save command will be the file name for the picture and it will be found in your sketch directory. Hints: You need to open 2 images at the same time. Let's say you have image1 and image2. When you call "loadPixels()", a list containing the colours of each pixel of the image is created. You can make a copy of this list and store in a variable called "pixels1". (To do this, use pixels1=pixels[0:]). Do this for each image separately so that you now have 2 lists, each containing the pixels for a single picture. Now you want to create a new image. You can do this using the global list "pixels" (since we have made copies of this list, the contents are no longer needed). You will create your new image by examining the values in the green screen image. If the value is "green", then your new picture will contain the colour of the pixel in the same spot in the background picture. Otherwise, your new picture will contain the colour of the green screen image. In other words, at each pixel location you made a choice, either choose the pixel in the green screen image or in the background.

why my programming not work?

image1 = None
image2 = None
def setup():
    size(852,480)
    image1 = loadImage("disney_background.jpg")
    image(image1,0,0,852,480)
    loadPixels()
    pixels1 = pixels[0:480]
    image2 = loadImage("frozen.jpg")
    image(image2,0,0,852,480)
    loadPixels()
    pixels2 = pixels[0:480]
    for i in range(width*height):
        r = red(pixels[i])
        g = green(pixels[i])
        b = blue(pixels[i])
    if g >0:
        pixels[i] = pixels1[i]
    else:
        pixels[i] = pixels2[i]

Explanation / Answer

Hii there,

Code will work fine .Could you please check whether this line is implemented properly or not .

"image1 = loadImage("disney_background.jpg");

jpg file name should match with it.

Thanks !

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote