Assignments | Course Home | Documentation | Lab Hours/Tutoring | Schedule | Submit

Saint Louis University

Computer Science 144
Introduction to Computer Science: Multimedia

Michael Goldwasser

Spring 2015

Dept. of Math & Computer Science

Programming Project 4

A Cutting Tool

Due: 11:59pm Wednesday, April 1, 2015


Contents:


Collaboration Policy

This assignment is more technical in nature. Therefore, we are going to use a common development style known as "pair programming" in which you are asked to work with one other student in developing a single piece of software to submit. If any student wishes to have a partner but has not been able to locate one, please let the instructor know so that we can match up partners.

It is vital that both students contribute to the development of the project. Please make sure you adhere to the policies on academic integrity in this regard.


Overview

The goal for this project is to develop something akin to a "cutting tool" that might be found in professional photo-editing software. You are to allow the user to indicate a polygon or curve in a photo, and then to create a mask to either isolate or remove the enclosed area of the picture.


Demonstration

Before giving the technical requirements for your software, we begin by providing a demonstration of our own software. Please note that you are not required to mimic our exact interface, nor are you required to include all features of our version. But it should give you some ideas of what is possible.

Our software has the following interface. You can indicate an enclosed area of the picture in one of two ways.

Once a shape has been indicated, you have the following choices:

At anytime, you may also do either of the following:

Image courtesy of blogger.com.

Requirements

As mentioned above, you do not have to recreate the exact demo above. Instead, we wish to outline some minimum functionality that must exist, and then leave it to you to explore adding extra features or improving on a convenient user interface. The minimum functionality for a complete project includes:

  1. You must give the user a way to select an area of the screen for editing, using either the point-to-point polygon approach in the above demo, or the mouse-dragging approach in the above demo. (Of course, you're welcome to do both if you wish.)

  2. You must visually display the selected shape as it is being drawn (i.e., akin to the use of red lines in the above demo).

  3. Once selected, you must provide a means for the user to crop the entire image down to include only the area within the selected shape (akin to use of the '+' key in our demo).

  4. You must provide some means for allowing the user to save an edited image to a PNG file.

Very importantly, you must submit a clear User's Guide for your interface as part of the submitted "readme" file outlined below.


Bells and Whistles

Beyond the minimum requirements, there should be ample opportunity to have fun with this project and expand the functionality and usability of this tool. Possibilities include (but are not limited to):


Advice

There are some distinct challenges in this project that build upon techniques we have seen earlier in this course.

  1. Using arrays to represent an arbitrary polygon
    Whether you allow the point-to-point or mouse-dragging for a user to define a shape, the underlying shape should be represented as a sequence of (x,y) points that define vertices of a polygon. (It's just for the mouse-dragging interface, there are many intermediate points on the polygon.) You should use arrays to store the ordered sequence of x- and y-coordinates along the polygon.

    Keep a count of the current number of points on the polygon, and add a new point for each mouse-click or mouse-drag, depending on your interface.

    Standard arrays in Processing must have a predefined size. While there are more advanced techniques for dynamically-sized containers, we are content with having you assume a reasonable maximum number of points that will ever be on a polygon. (Our software uses 10000 as the maximum.)

    Feel free to review our earlier examples of array usage.

  2. Using a mask to crop an image
    Once a polygon has been selected, to use it to crop or mask the image, you will need to create a custom PGraphics instance with a polygon drawn as a mask. Feel free to review our earlier examples regarding masking.

  3. Making an interactive sketch
    One of the challenge aspects will be monitoring the user's interactions to control the software. To be successful, you will likely need to keep track of several various "state variables" to denote the current status of the software. For example, a key-press may have different effect if pressed whether it is before, during, or after the user's defining of a shape. You may want similar distinctions in the way your software reacts to mouse gestures, depending on the current state.

    To track these changes in states and vary behavior based on them, you will likely want to have one or more boolean variables or integer variables used to represent current status.

  4. Using PImages and PGraphics
    While you will likely need to use a PGraphics instance to achieve the masking effects, you may also find more general use of PImage and PGraphics instances to effectively keep "off-screen" versions of various artifacts of the imagery.

Equally important, this project simply has more complexity than anything we've done so far. The key is to stay organized, and to break down the task into many more managable subtasks. We offer some general for good software design techniques that are often used to manage the complexity of a project.


Grading Standards

The assignment is worth 70 points, which will be assessed as follows:

In addition to the above points, we will happily award extra credit points to those who go significantly beyond the minimal project requirements.


Submitting Your Assignment

For this project, only one member of a partnership needs to submit the work, but both members of the team should be clearly identified within the header of the source code and the readme file. We ask that you submit the following three files:

  1. The .pde file that contains the actual Processing source code you've written

  2. A separate 'readme' text file, as outlined in the general webpage on programming projects. Of particular note for this project, your readme file must include:

  3. A .png image of an edited image that was created with your program. Note well that we ask for the png file format because it provides support for transparent layers within an image. (jpg format does not support transparency.)

Please see details regarding the submission process from the general programming web page, as well as a discussion of the late policy.


Michael Goldwasser
Last modified: Tuesday, 17 March 2015