COMPFOR 221: Digital Media with Python

Who Should Take This Class: Anyone who wants to learn how digital media are created and manipulated. Ever wondered how Photoshop filters work, or how a keyboard can make trumpet and dog sounds, or how people can be made to disappear in videos? That’s what we’ll explain, and you’ll make them yourself.

The focus of this class is on digital media, where Python is our tool. We spend much of our time talking about media are digitized in order to match the way that humans sense the world.

Programming in Python: The kind of programs we make are similar those in COMPFOR 121, but in Python. We’re using Google Collaborative Notebooks (like Jupyter Notebooks), which means that anyone can do all the programming in this course from a Web browser without installing anything.

Course Goals

At the end of this class students will be able to:

  • Create and design software for manipulating and creating digital media.
  • Be able to describe how text, images, sounds, and video are represented on the computer.
  • Be able to write Python programs that transform text, images, and sounds through filters.
  • Be able to write Python programs that generate text, images, sounds, and videos.
  • Be able to explain what an object is in object-oriented programming, and use objects to define digital media
  • Use a professional media library and API to manipulate digital media

Homework and Projects: Students five programs for homework, two larger projects and one final project.

  • Homework #1: Encode and decode text messages
  • Homework #2: Create two image filters and make a collage using Google Slide or Powerpoint of your own pictures manipulated with your own filters.
  • Project #1: Now, make the collage with all the picture placement with Python, then mirror the whole canvas.  Here are a couple of great examples:
  • Homework #3: Create two new sound filters
  • Project #1: Create a sound collage of several sounds spliced together with digital manipulations
  • Homework #4: Create a movie using a digital video special effect
  • Homework #5: Create an image effect using the Python Imaging Library
  • Final Project: Create a movie in Adobe Premiere (using the U-M site license) with audio and video segments created with Python.

Grading

  • 20% – Five Homework Assignments in Python turned in via Canvas
  • 15% – Two (larger) Projects in Python turned in via Canvas
  • 25% – Six online quizzes. (There will be seven quizzes, lowest score will be dropped. They are released on Thursday and due on Sunday.)
  • 20% – Final Project. Students will be asked to create a video with both visual and audio components of at least 30 seconds in length, with all elements generated through their programs.
  • 20% – Participation (in-class activities). Typically, 90% attendance gives you 100% of participation points, 80% gives you 90% of participation points, 70% attendance gives you 60%, 60% gives you 50%, and no participation points if you participate for less than 50% (e.g., you come to only half the classes where we have in-class activities). We use iClickers in this class.

There are no midterm or final exams.

Example Course Schedule, from Fall 2024

What programming looks like in this class

Below is an example of implementing a picture filter where we generate a grayscale by averaging the red, green, and blue parts of each pixel:

To edit sounds, we change individual samples in a sound. Here’s a piece of Python code that increases the volume in the first half of the sound.

def increaseVolumeFirstHalf(sound):
  samples = getSamples(sound)
    for i in range(0,int(len(samples)/2)):
      v = getSampleValueAt(sound,i)
      setSampleValueAt(sound,i, 2 * v)

The below example from the Google Collaborative Notebook increases the volume in all the samples — see how the graph gets bigger.

Media Computation

This course is a kind of “Media Computation” course. Originally developed at Georgia Tech in the early 2000’s, it’s been successfully taught all over the world.  Here a couple examples of Media Computation in videos: