Lab 1: Mean Image Median

Overview

In this assignment, you will read images in the plain PPM format and produce an image that contains the median and average of the input images.

Video introduction for the lab

Pre-Lab (DUE BEFORE LAB - see due date in Canvas)

As part of the pre-lab activity you will see how to use GitHub Classroom to start your lab assignment and submit it when you are finished. When watching the video below, consider the following.

  • How to start a new project from your GitHub repository
  • How to commit changes to your local repo
  • How to push changes from your local repo to GitHub

The project is cloned from the GitHub repo to your local machine at the three minute mark in the video. You will likely need to authorize IntelliJ to access your GitHub account. Hopefully the process is simple enough, but you can see screenshots for what to do in Figures 13-16 of this page.

What Must Be Done by the Pre-lab Due Date?

Assignment

Your program must accept the following input information:

Note that all input files must have the same dimensions.

Your program may use command line arguments or console input to obtain the input information. The program must produce an output image that, at each location in the image, contains either the median or average of the (red, green, and blue) components of all of the input pixels at that location.

Details

mocked Package

You are provided with a mocked.Image class implementation containing the following methods:

You are also provided with a mocked.WritableImage class implementation which extends mocked.Image and contains:

The mocked.PixelReader interface provides one method: int getArgb(int x, int y) which returns the 32-bit integer value of the color of the pixel located at x, y. The mocked.PixelWriter interface provides one method: int setArgb(int x, int y, int argb) which sets the 32-bit integer value of the color of the pixel located at x, y.

Lab1 Class

You must also implement the Lab1 class that will contain your main program.

MeanImageMedian Class

You must implement the MeanImageMedian class that will contain several methods to be called by your program to complete the requirements of the assignment. Your class must have the following public class methods:

Several private helper methods are provided in the MeanImageMedian class to help you work with ARGB (alpha, red, green, and blue) values. You are encouraged to identify and implement additional private methods in the MeanImageMedian class.

Plain PPM Format

Your program must support the plain PPM format for 24-bit color images. Each pixel in the image is represented by an 8-bit integer value (between 0 and 255).

The contents of a PPM file representing an image the is two pixels wide and three pixels tall is shown below:

P3
2 3
255
255 255 255   255 255 255
  0   0   0   255   0   0
  0 255   0     0   0 255

Exception Handling

If any problems are encountered with reading the input files or writing the output file, the program should display a useful error message to the console and terminate gracefully. The program should not crash or display any exceptions.

Just For Fun

Ambitious students may wish to:

Acknowledgement

This laboratory assignment, developed by Dr. Chris Taylor.

See your professor's instructions for details on submission guidelines and due dates.