<< Return to Labs Page

Prelab 10 : Coordinates in Pictures

Reading

Addressing pixels in an image

  1. Describe the difference between the three different loops below. That is, what does each do? How many times is Hello printed in each case? for i in range(4): print "Hello" while timeRemaining(4): print "Hello" while True: print "Hello"
  2. Consider this code and fill in the blanks below:
    for x in range(0,1000):
      print x # First command
    print x #Second command
    

    1. The number of times the first print command is executed: ...........
    2. The number of times the second print command is executed: ..........
  3. What does the following code do? What will the resulting image (myPic look like? MAX = 255 W = 100 H = 100 # Create the blank image myPic = makePicture(W, H) # Fill in each pixel with x+y shade of gray for x in range(W): for y in range(H): grayVal = (x+y)%(MAX+1) setPixel(myPic, x, y, makeColor(grayVal, grayVal, grayVal))
    
    

Find images for Chroma Key

Find two images for use with the chroma key technique and upload them to your public_html directory using WebFiles. One image should have some object or person in front of a monochromatic background. The other image will serve as a background for the object in the previous image. Both the foreground and background images must be the same size (i.e. same width and height measured in pixels).

Submitting

Bring your anwers with you to lab and upload your images prior to lab.