Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Excersise Set 2 (Part 5)

Part 5 Answers
Match the original and its modified image to the code that created the modified copy.


















Originals External Image External Image External Image External Image External Image
Modified External Image External Image External Image External Image External Image

















(1)
def changeColorSquares(file):
  picture = makePicture(file)
  openPictureTool(picture)

  for pixel in getPixels(picture):
    r = getRed(pixel) 
    g = getREMOVED(pixel)
    b = getBlue(pixel)

    if ( (r > 130) and (g < 200) and (b < 200) ):
      setRed(pixel, 0)
      setREMOVED(pixel, 0)
      setBlue(pixel, 255)
    else:
      if ( (r < 130) and (g < 200) and (b < 200) ):
        setRed(pixel, 255)
        setREMOVED(pixel, 255)
        setBlue(pixel, 0)
        
  repaint(picture)


(2)
def changeColorSquares(file):
  picture = makePicture(file)
  openPictureTool(picture)

  for pixel in getPixels(picture):
    r = getRed(pixel) 
    g = getREMOVED(pixel)
    b = getBlue(pixel)

    new_color = makeColor(255-r, 255-g, 255-b)
    setColor(pixel, new_color)

  repaint(picture)


(3)
def changeColorSquares(file):
  picture = makePicture(file)
  openPictureTool(picture)

  for pixel in getPixels(picture):
    r = getRed(pixel) 
    g = getREMOVED(pixel)
    b = getBlue(pixel)

    if ( (r < 100) and (g < 100) and (b>10) ):
      setRed(pixel, 128)
      setREMOVED(pixel, 128)
      setBlue(pixel, 128)
 
  repaint(picture)


(4)
def changeColorSquares(file):
  picture = makePicture(file)
  openPictureTool(picture)

  for pixel in getPixels(picture):
    r = getRed(pixel) 
    g = getREMOVED(pixel)
    b = getBlue(pixel)

    if ( (r < 100) and (g < 100) and (b > 10) ):
      setRed(pixel, 255)
      setREMOVED(pixel, 255)
      setBlue(pixel, 0)
    else:
      if ( (r > 10) and (g < 100) and (b < 100) ):
       setRed(pixel, 0)
       setREMOVED(pixel, 255)
       setBlue(pixel, 0)

  repaint(picture)


(5)
def changeColorSquares(file):
  picture = makePicture(file)
  openPictureTool(picture)

  for pixel in getPixels(picture):
    r = getRed(pixel) 
    g = getREMOVED(pixel)
    b = getBlue(pixel)

    if ( (r > 175) and (g < 215) ):
      setRed(pixel, 0)
      setREMOVED(pixel, 255)
      setBlue(pixel, 255)
    else:
      if ( (r < 200) and (g < 200) and (b < 200) ):
        setRed(pixel, 255)
        setREMOVED(pixel, 255)
        setBlue(pixel, 0)

  repaint(picture)

 


Link to this Page