Sie sind auf Seite 1von 2

cImage module We will be using the Python file cImage.

py that contains code for reading and displaying images. Put the following line of code (preferably at the top of your own Python file) to tell the computer you will be using functipons/objects in from cImage.py: from cImage import * Image fundamentals: Pixel Object: an individual dot in an image. Pixel object stores three color intensities: red intensity, green intensity, and blue intensity. Each intensity is between 0 and 255. Color Red Green Blue White Black Yellow Pink Red 255 0 0 255 0 255 255 Green 0 255 0 255 0 255 0 Blue 0 0 255 255 0 0 255

Image object: A matrix (2-dimensional array) of pixels.

h =height of image

w = width of image ImageWin object: Can be thought of as a canvas that can display images. Nothing gets displayed on the canvas unless you draw it. Some very useful lines of code: #displaying an image from cImage import * myImage = FileImage( whatever.gif ) w = myImage.getWidth() h = myImage.getHeight() myWindow = ImageWin( any title you want , w, h) myImage.draw(myWindow)

#change the top right pixel to a red pixel topRightPixel = myImage.getPixel(0, w-1) newTopRightPixel = Pixel(255, 0, 0) myImage.setPixel(0,w-1, newTopRightPixel) myImage.draw(myWindow) myWindow.exitOnClick()

First image processing assignment: Today: Load Jellyfish.gif, make a green horizontal line that goes across the middle of the image. Tomorrow: For the file Jellyfish.gif, switch the red and blue intensity values for EVERY pixel in the image.

Das könnte Ihnen auch gefallen