Developing Algorithmic Multimedia Exercises (CSC-397 98S)

[Front Door] [Students] [Outlines] [Handouts] [Exercises] [Libraries] [Lab Manual]

Algorithms for Facial Distortion


Among the many benefits of using computers for image editing is the ability of the computer to distort components of the image, enlarging some, reducing others, twisting and turning others. In this exercise, you will be developing algorithms that simulate some of the facial manipulations provided by editing applications like Kai's Power Goo. In particular, you will consider appropriate algorithms for enlarging or reducing part of a person's face and, optionally, develop variations on these algorithms.


In order to complete this exercise, you will need a picture or pictures of yourself or your friends to manipulate. Take one or more such pictures and put them on your Zip disk.

Spend some time playing with Kai's Power Goo, concentrating on the components that allow you to expand or contract a person's features. Make notes to yourself as to how one describes a feature and indicates operations on that feature. See if you can determine what happens to each pixel during these manipulations.

Describe the set of inputs you would expect to use in an algorithm that expanded or contract a feature. Then, sketch an algorithm that you might use to manipulate features (e.g., shrink or enlarge someone's nose).


Now that you've begun to think about the task of manipulating features, you can begin to implement algorithms to support this task. Here is one possible algorithm for expanding part of an image, written in a generic procedural psuedocode.

/* Scale part of an image (represented as a series of points in the
   precondition: 100 <= percent <= 200
   precondition: each point is within the image
   postcondition: the selected portion of the image is scaled
expandImage(image, percent, points)
  let new_image be a copy of image
  for each point in points
    determine the new location or locations for that point
    for each new location
      if the location is within the image
        merge the RGB values of the point in the original with the
          RGB values of the new location in the new image
  return new_image

Implement this algorithm, filling in appropriate details. It is likely that you will want to take advantage of some or all of the following functions from our image utility library.

Additional Steps

You need only complete these additional steps if you have sufficient time. They are intended to help you further understand the problem, but are not necessary to basic understanding or utility.

As you experiment with your algorithm, you may find that that the scaled images don't always look quite right. It turns out that scaling of a group of points can be better achieved if the scale factor and shift factor depend on the distance of the point from some "base point." Extend your algorithm to incorporate this change. Initially, you may want to hard code the base point and function used to determine scale and shift factors. However, it would be better if the final version of your function took base point and functions as parameters.

You may also find that you have to make accomodations in the surrounding pixels as you expand some parts of your image. For example, you may need to shift some pixels to the side to accomodate your image, or even shrink portions of the image.

[Front Door] [Students] [Outlines] [Handouts] [Exercises] [Libraries] [Lab Manual]

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

Source text last modified Wed Nov 5 14:48:50 1997.

This page generated on Mon Jan 19 09:52:46 1998 by SiteWeaver.

Contact our webmaster at