Documentation for images.py

One-dimensional approaches (useful for first two assignments)

win = ImageWin(width, height, title)
Return a window object that can be used for drawing an image.
image = FileImage(filename)
Return an image object constructed from a particular image file.
image = EmptyImage(width, height)
Return a new image object with the designated width and height in pixels.
image.copy()
Return a copy of this image.
image.getNumPixels()
Return the number of pixels in this image.
image.getPixel1D(location)
Return a pixel at the given location, considering the pixels as one long 1 dimensional sequence. If a color image, the pixel is returned as a Pixel object. For example, image.getPixel1D(10) returns Pixel(10,200,156). If a gray image, the pixel is returned as a single integer representing brightness.
image.setPixel1D(location, color)
Set the color of a pixel at the given location, considering the pixels as one long 1 dimensional sequence. If a color image, the color must be specified as a Pixel object, where the rgb values are between 0 and 255. For example, image.setPixel1D(10, Pixel(10,200,156)). If a gray image, the brightness must be specified as an integer from 0 to 255. For example, image.setPixel1D(10, 240).
image.draw(win)
Display the image in the window.

Pixel methods

singlePixel = image.getPixel1D(location)
singlePixel.getRed()
singlePixel.getGreen()
singlePixel.getBlue()
Gets the red, green, or blue value from a particular Pixel object. Values range from 0 to 255.
singlePixel.getColorTuple()
Get all three color values (red, green, blue) from a Pixel object as a tuple.
Pixel(red, green, blue)
Create a Pixel object with color values (red, green, blue).

Two-dimensional approaches (useful for third assignment)

image.getHeight()
Return the height of this image.
image.getWidth()
Return the width of this image.
image.getPixel2D(x,y)
Return a pixel at the given x,y coordinate. The pixel is returned as a Pixel object. For example, image.getPixel2D(10,10) returns Pixel(10,200,156).
image.setPixel2D(x,y,color)
Set the color of a pixel at the given x,y coordinate. The color must be specified as a Pixel object, where the rgb values are between 0 and 255. For example, image.setPixel2D(10, 10, Pixel(10,200,156)).