Course Home | Documentation | Lab Hours/Tutoring | Projects | Quizzes | Schedule | Submit

Saint Louis University

Computer Science 1050
Introduction to Computer Science: Multimedia

Michael Goldwasser

Spring 2016

Dept. of Math & Computer Science

Lecture Notes: Images


PImage data type

A PImage object is the equivalent of an "off-stage" canvas that stores an array of pixels. We can examine and manipulate the color settings for those pixels and later render the PImage to an actual canvas.


loadImage() function

Examples:

Many common file types are supported (e.g., jpg, png), but this may be system dependent.


createImage() function

We can also create a new (blank) PImage object by using the createImage() function with a given width and height and color model. Examples are:


background() function

We have previously used the background function to set the entire canvas background to a particular color. It is also possible to set the entire canvas background to a given image, as in

background(slu);
although this only works if the canvas has width and height that precisely match the image.


image() function

We can display a particular PImage object on our canvas, with top-left corner at (x,y) using a command of the form:

image(slu, x, y);

You can also use transformation functions such as scale and rotate to alter the canvas coordinate system before rendering an image.


Useful functions of a PImage object

For the following examples, assume our image is named with variable img.


Additional "Bells and Whistles"

There exists functionality for many common image processing tasks (although, for the purpose of exploration, we may later develop our own low-level implementations for many of these). To demonstrate several of these, we rely on the following reference image.


Michael Goldwasser
CSCI 1050, Spring 2016
Last modified: Wednesday, 18 February 2015
Course Home | Documentation | Lab Hours/Tutoring | Projects | Quizzes | Schedule | Submit