SimpleImage Reference

Basic SimpleImage Functions

The simple CS106AP "SimpleImage" code provides basic digital image processing code for you to call.

Advanced SimpleImage Functions

Range Loop

The "foreach" above is the easiest way to loop over all the pixels. However sometimes you want to write loops to access pixels by their x,y coordinates. Here is the canonical nested range loops to access all the pixels in an image. This loop does the top row (y=0), then the next row (y=1) and so on.

def example(filename):
    image = SimpleImage(filename)
    for y in range(image.height):
        fox x in range(image.width):
            pixel = image.get_pixel(x, y)
            # do something with pixel
   = // 2
    return image