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 Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Spring 2004: Generalized image filter

(Return to Sp2004 Midterm 1 Review)

Questions, answers, comments on answers, comments on questions?



Amy Howard

def changeRGB(picture, amountRed, amountGreen, amountBlue):
    for p in getPixels(picture):
        setRed(p, getRed(p)*(amountRed + 1))
        setGreen(p, getGreen(p)*(amountGreen + 1))
        setBlue(p, getBlue(p)*(amountBlue + 1))

Once again, Amy, looks good. Ashley Coker


Amelia Cipolla

def changeRGB(picture, R, G, B):
    for p in getPixels(picture):
      red=getRed(p)
      green=getGreen(p) 
      blue=getBlue(p)
      setRed(p, red*(1+R)) 
      setGreen(p, green*(1+G))
      setBlue(p, blue*(1+B)) 

Is this better??   






Amelia, remember that the argument to getRed, getGreen, and getBlue is a pixel. Adam Wilson
Right now, your code is setting the green pixels and the blue pixels to 1 plus whatever the value for "R" is. Is that what you want? Maybe the setGreen should be 1 + ?? and the setBlue should be 1 + ?? (You fill in the ??'s) Ashley Coker
YES it's better now. :o))) Ashley Coker

Jalencia Adams
def changeRGB(picture, amountRed, amountGreen, amountBlue):
for p in getPixels(picture):
red=getRed(p)
green=getGreen(p)
blue=getBlue(p)
setRed=(p, red (amountRed + 1))
setGreen=(p, green (amountGreen + 1))
setBlue=(p, blue (amountBlue + 1))


Margaret McIntosh
def changeRGB(picture, amountR, amountG, amountB):
for p in getPixels(picture):
setRed(p, getRed(p)+ (getRed(p)amountR))
setGreen(p, getGreen(p) + (getGreen(p)amountG))
setBlue(p, getBlue(p) + (getBlue(p)amountB))


Jalencia, why do you have = following setRed, setGreen, setBlue? Margaret, using the get function rather than 1 is a good idea! Everybody try to have a look at the FAQ page to see how to format code so that it appears correctly on the Coweb though!

no more
def changeRGB(picture, amountR, amountG, amountB):
for pixel in getPixels(picture):
newRed = getRed(picture)(amountR + 1)
newGreen = getGreen(picture)(amountG + 1)
newBlue = getBlue(picture)(amountB + 1)
newColor = makeColor(newRed, newGreen, newBlue)
setColor(pixel, newColor)

I know it's long, but does it work?

no more
By the way, where are these "html" and "pre" tags so my code is not messed up?

Your last two lines have the correct form – i.e. multiple inputs to a function appear in a single set of parentheses, separated by commas. The preceding three lines need to be like that.

As for the tags, look in the FAQ page inside "Help". The "code" tags should also do the trick. Colin Potts

def changeRGB (picture, amountRed, amountGreen, amountBlue):
  for p in getPixels (picture):
    setRed (p, getRed(p)*(amountRed +1))
    setGreen (p, getGreen(p)*(amountGreen+1))
    setBlue (p, getBlue(p) (amountBlue+1))

When I try to run this, and the other ones posted here in JEs, I get an error. I can't figure out what is wrong. Jes tells me "your code contains atleast one syntax eorr, meaning its not legal jython. What should I do?

Oh yeah, I had the indentations already, they just didn't show on this. Sabrina Hassanali

Look at the final line. There's something missing. Colin Potts

Link to this Page