CSC-107: Creative Computing

Creative Computing Collage

Course Overview

Creative Computing uses a media computation theme to learn about computers and computing. You will learn to program a computer using the Python programming language, to manipulate images, video and text.

The first part of the courses focuses on digital images as a way to introduce variables, decision making statements and loops. You'll learn how to change individual pixels in an image, to change their color, or even their orientation. The effects you'll see include making a picture greyscale, mirroring, making pictures negative and blending pictures together. All of these effects are achievable with software such as photoshop, but in this course we will use these effects to learn the fundamentals of how we program computers to solve tasks - not solely tasks related to images, but any task that requires computation.

During the course, there are two large media projects. The first is to create a digital image collage, by using your programming skills to manipulate images. The picture at the top of this page is one example, and you can see more in the gallery of collage images from previous classes.

The second half of the course focuses on digital sounds, to reinforce the skills learned in the first half, and to demonstrate that these skills are transferable - that you are learning the fundamentals of programming, which apply to different media, as opposed to learning specific image manipulation skills.

Language & Resources

In this course you will learn to program Python. In order to make digital media manipulation easier, we use a program called JES, which allows you to use Python on images and sounds. You can download these resources for your own computer if you wish.

In class, you are required to use our lab iMacs. However, when working on your projects outside of class, you have a choice. If you'd like to continue using our iMacs, feel free! We have three spaces that you can use:

All of these labs are available to you 24/7 using your ID card, except when classes are being held in them.

Course Text

Introduction to Computing and Programming in Python, A Multimedia Approach, 2nd Edition. Mark J. Guzdial, Barbara Ericson.

Example Assignment

1. Create the function: copyPicture(source,target,targetx,targety), which takes a source picture, a target picture, and a target x and y coordinate, copies the source picture starting at the x and y coordinates in the target canvas. The function should return your target picture.

Upload an image created using this function to Nexus.

2. Cropping a picture. Create a copy function that takes 8 parameters: a source picture, a destination picture, an x and y location, a width and height, and a targetX and targetY location. The function will copy an area the size of the width and height parameters from the source image starting at the x,y location to the targetX, targetY location in the destination picture. Your function should return a picture.

Create an image using your function and post it on your webpage, and upload it to Nexus.

example of copy 8

Deliverables:
1. Submit your python file through nexus and a hardcopy of the code in class.
2. Upload your image files to nexus.
3. For the last part, also post the image to your webpage.

Example Lab

Part I - Posterizing

Recall the posterize function from class. This function reduced the colors in an image to two colors, black or white, and chose the end color for each pixel based on the luminance (greyscale value) of that pixel. The goal of posterizing is to reduce the number of colors in an image by mapping lots of possible colors to a single color.

For this lab, you will write a python program that takes an image and reduces the number of colors to 8 colors. We get down to 8 colors by assigning either 0 or 255 for each of the Red, Green and Blue parts of a single pixel (2^3 possible combinations gives 8 total colors). So your program will reduce an image to the following 8 colors. In each color the R, G and B values are either 0 or 255. So your program will reduce an image to the following 8 colors. In each color the R, G and B values are either 0 or 255:


Black
r = 0
g = 0
b = 0

Red
r = 255
g = 0
b = 0

Green
r = 0
g = 255
b = 0

Blue
r = 0
g = 0
b = 255

Yellow
r = 255
g = 255
b = 0

Magenta
r = 255
g = 0
b = 255

Cyan
r = 0
g = 255
b = 255

White
r = 255
g = 255
b = 255


For this function, rather than choosing your color based on the total luminance of a pixel, you will be choosing the R, G and B value based on the intensity of that channel. Set a threshold value of 127, and compare each R, G and B component to that threshold. If it is equal to or above the threshold, set that channel to 255. If it is below the threshold, set the value to be 0.

Your posterize function should:

Receive a picture as an parameter.
Change the selected image to an eight color posterized image.
Display the posterized image.

Try out your function on a number of images. Because you will be reducing the number of colors so dramatically, some images may look horrible when you transform them. See if you can find an image for which this transformation works reasonably well. Save this as the file posterized.jpg and add it to your webpage.

Part II - More transformations

In class, we created a function to scale up an image. Can you edit this function to scale DOWN a picture by a factor of 2 in each dimension? Call the new image scaled_down.jpg. Add the scaled down picture to your webpage.

HINT: You need to change the range of targetx, targety values.
HINT: You need to change the way we get pixels from the source. Instead of sampling each pixel twice, we need to skip over some pixels.

You have previously created mirror functions, that moved pixels from one place to another. We can create a different effect, based on moving the location of pictures. We can rotate a picture. Create a rotate picture function, that takes a picture and a target as parameters. THIS will only work for now if you copy it to position 0,0 in the target picture.

Go through the source picture (or part of the source picture) using range functions. When selecting the TARGET pixel, the correct code is:

getPixel(target, targetY, width - targetX - 1)

Rotate an image onto a blank image, save it as rotated.jpg, and upload the image to your web page.

Assignments & Grades

There will be weekly homework exercises. Homework exercises are for you to play with and reinforce the concepts we talk about in class. Each person must hand in his or her own solution. Where these exercises require python programs, you MUST hand in working code, including test measures. This will be explained more fully at the appropriate time.

There will be two programming projects. These projects will combine different programming concepts and multimedia techniques, and provide opportunities for creativity. Each student must complete his or her own programming project. You may discuss algorithms with each other, but you may NOT look at each other's code. To complete these projects on time, it is critical that you start each as early as possible and get help as soon as possible when needed.

There will be labs where you will work on exercises in-class and receive help from the lab assistant, your peers and instructor.

There will be one in-class midterm exam, and a final exam that must be completed individually. There may be "pop quizzes" and independent in-class exercises. The intent is to motivate you to keep up and provide feedback on your progress. Learning to program is like learning a foreign language: if you do not speak it during some part of every day your progress will be quite slow.

Grade Allocation

Schedule

Subject to change. Be sure to check for updates on Nexus: http://nexus.union.edu/