LAB 2

 

the function for this was:

# Recipe 15: Create the negative of the original picture
def negative(picture):
...for px in getPixels(picture):
...red=getRed(px)
...green=getGreen(px)
...blue=getBlue(px)
...negColor=makeColor( 255-red, 255-green, 255-blue)
...setColor(px, negColor)

This function creates a negative of the orginal picture by assigning new RGB values for each pixel (255-red,255-green, 255-blue). This simply make the color of each picture opposite of what it was before.

 

 

The function for this was:

#Lab2: Making a sunset as three Functions and generalizing decreaseBlue and decreaseGreen
def makeSunset(picture):
...reduceBlue(picture, 0.8)
...reduceGreen(picture, 0.8)

def reduceBlue(picture, blueValue):
...for p in getPixels(picture):
......value=getBlue(p)
......setBlue(p, value*blueValue)

def reduceGreen(picture, greenValue):
...for p in getPixels(picture):
......value=getGreen(p)
......setGreen(p, value*greenValue)

This function decreases the value of Blue and Green in each pixel by any amount the programmer chooses. The result of the value of reduction that I chose (0.8) gives the picture a slight hue of redness which makes it appear as though it were a sunset.