Topic 1 - Variables and Data Types
Topic 2 - Conditionals and Strings
Topic 3 - Loops
Topic 4 - Arrays
Topic 5 - File Handling
Semester 1 Projects
Topic 6 - Classes/Objects and Methods
Topic 7 - ArrayLists
Semester Projects

Introduction

You should do this project if…

  • You would like to know how Computer Science and Graphic Design can be combined.
  • You would like a moderate challenge while getting to learn some useful image processing concepts.
  • You enjoy processing images and would like to make your own filters.
  • You feel comfortable with Java and would like to understand more intermediate concepts.

Starter Code Files

https://github.com/emlag/DarkRoom

Project Setup

Possible Troubleshooting

Introduction

You’ve probably had occasion to use some sort of image-editing software, whether it is Adobe Photoshop, Adobe Illustrator, online image-editing tools, or others. In this assignment, you will build a simple version of one of these image editors that implements several useful operations.

The purpose of this assignment is to practice using arrays (1D and 2D) in your programs to manipulate images. We provide you with a completed GraphicsProgram called DarkRoom.java that contains all of the user interaction behavior; you have to write the image manipulation algorithms in a file named DarkRoomAlgorithms.java .

If you would like to implement any extensions, please implement them in separate files or make a separate submission. Clearly comment what extensions you have implemented.

Output Comparison

For this assignment, there is a built-in output comparison tool to check your output. In DarkRoom, to compare the displayed image to a particular image file, click “Compare To Image” and select an image to compare it to. 

In the starter project’s res/ folder, we include sample images with which to test your algorithms (or you may add your own). In the output/ folder, we include sample output images for the filters you will implement. Please see the Demo JAR posted on the course website for more sample output. 

DarkRoom Overview

As mentioned previously, the starter project contains a completed DarkRoom.java file that displays and handles all onscreen buttons, controls, saving and loading images, and more. Your work will be in DarkRoomAlgorithms.java, where we have left blank methods for each of the image algorithms you must implement. Specifically, each method accepts a GImage parameter representing the current onscreen image, and should create and return a new GImage of that image after that algorithm has been applied. As a reminder, if you have a 2D array of pixels named pixels, you can create a new GImage with those pixels by saying:

GImage image = new GImage(pixels);

You will implement the following image manipulation algorithms: 

negative
greenScreen
rotateLeft
rotateRight
flipHorizontal
crop
blur
equalize

Your algorithms should not use any instance variables; each algorithm can be solved on its own without these. Each algorithm should work on any image of any size, including very large images or very small images such as 1×1 pixels, etc. When describing the algorithms we may refer to pixels in the format (r, g, b) such as (24, 191, 65) to indicate a pixel with a red component of 24, green component of 191, and blue component of 65. 

Working With Pixels

Each method has a “source” parameter, which is the 2-D array that you’ll be working with. You can use source.getPixelArray() which will return the 2-D array you need. 

You can access the individual components of a single pixel value, and make a new pixel value, by doing the following: 

// get pixel, e.g. from pixelArray
int pixel = ...

// get individual color components of this pixel
int redValue = GImage.getRed(pixel);
int greenValue = GImage.getGreen(pixel);
int blueValue = GImage.getBlue(pixel);
int alphaValue = GImage.getAlpha(pixel);

//make a new pixel value (with values r, g, b)
int newRed = ...;
int newGreen = ...;
int newBlue = ...;
int newPixel = GImage.createRGBPixel(newRed, newGreen, newBlue);