greyscaleworks - height = oldimage.getHeight newim =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
from cImage import * def grayPixel(oldpixel): intensitySum = oldpixel.getRed() + oldpixel.getGreen() + oldpixel.getBlue() aveRGB = intensitySum // 3 newPixel = Pixel(aveRGB,aveRGB,aveRGB) return newPixel def makeNegative(imageFile): myimagewindow = ImageWin("Image Processing",600,600) oldimage = FileImage(imageFile) oldimage.draw(myimagewindow) width = oldimage.getWidth()
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: height = oldimage.getHeight() newim = EmptyImage(width,height) for row in range(height): for col in range(width): originalPixel = oldimage.getPixel(col,row) newPixel = grayPixel(originalPixel) newim.setPixel(col,row,newPixel) newim.setPosition(width+1,0) newim.draw(myimagewindow) myimagewindow.exitOnClick() makeNegative("guy.gif")...
View Full Document

This document was uploaded on 12/14/2010.

Ask a homework question - tutors are online