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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2006 Midterm 1 Review - Color-blind

Questions?


I'd like to know if I'm on the right track or if it's correct. The program works but I'm not sure if it's correct.
def redGreenOut(picture):
  for p in getPixels(picture):
    greenValue = getGreen(p)
    redValue = getGreen(p)
    setRed(p, (greenValue + redValue)/2)
    setGreen(p, (greenValue + redValue)/2)
  show(picture)
  return picture


Thanks!! Brittany Walsh

Looks good to me. Amanda Bennett

Why does JES return an error message when you try to perform this exact function?
charlie blackmon
Works for me. Did you remember to load it? Colin Potts

shouldn't it be redValue = getRed instead of getGreen?
Aha! Colin Potts

Come on BB....Stacy Schwaiger

My bad yo... I meant the other way :D

why do you put return picture at the bottom?
For every function you write, it's a good idea to return the picture, so that it can be used later. Its optional unless specified in the question. So, in the exam, make sure whether we're asking you to show the picture or return the picture or both. - Bobby Mathew

def redGreenOut(picture):
  for px in getPixels(picture):
    newRed=(getRed(px)+getGreen(px))/2
    newGreen=newRed
    newBlue=getBlue(px)
    setColor(px, makeColor(newRed, newGreen, newBlue))
  show(picture)
  return picture


I did it this way. Is there anything wrong with this, cause it works, but I was just wondering if there was anything technically wrong with it.

Leah McClellan
This is fine. It's a matter of programming style. I like the way you create new values for each color, calculating the red, copying the green from the newly calculated red, and just cloning the old blue. Nice. Colin Potts

def redGreenOut(myPicture):
  for pixel in getPixels(myPicture):
    avg=(getRed(pixel)+getGreen(pixel))/2
    setGreen(pixel, avg)
    setRed(pixel, avg)





Link to this Page