This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: # hint: you sometimes need to use extra variables myList = [hello,hi,yippee] # initialization item = myList number = 0 while ( number < len(myList)): print(item) # change of state number = number + 1 item = myList[number] We want to turn all pixels into gray pixels of different shades. White: 255,255,255 Black: 0,0,0 What characteristic makes a pixel be gray? Gray pixels have all values the same. Given a color pixel with three different values, I need to choose what value to give all three that is the same. getRed(), getBlue(), getGreen() Lets take the average of the three values and make that my gray value. def makePixelGray(pixel): red = pixel.getRed() green = pixel.getGreen() blue = pixel.getBlue() gray = (red + green + blue) // 3 newPixel = cImage.Pixel(gray,gray,gray) return newPixel...
View Full Document
This note was uploaded on 12/27/2011 for the course CMPSC 8 taught by Professor Franklin during the Fall '09 term at UCSB.
- Fall '09