Lab 5: Mean Image Median Revisited

Overview

In this assignment, you will read and write images in a custom binary format. In addition, you will refactor the calculate mean and median methods to use a functional programming approach and support other transformations.

Video introduction for the lab

Assignment

The assignment builds on lab 3. Begin by incorporating feeback from your instructor on the first three lab assignments.

Deprecation of Methods

You should deprecate the calculateMeanImage() and calculateMedianImage() methods by adding the deprecated tag to the javadoc and placing the @Deprecated annotation before each method.

    /**
     * Calculates the median of all the images passed to the method.
     * ...
     * @deprecated use {@link #generateImage(Image[], String)} instead
     */
    @Deprecated
    public static Image calculateMedianImage(Image[] inputImages) {

Functional Interface

Create a functional inteface, Transform, with one method, apply() that accepts an array of integers and returns an integer.

Deprecation Replacement

The deprecated methods must be replaced with the following methods:

Update the controller code so that generateImage() is called in place of the deprecated methods.

MSOE Image Format

Your program must support the .msoe file extension that represents images using binary image format described in this section. In order to do this, private methods named readMSOEImage() and writeMSOEImage() should be created that match the behavior for the corresponding read/write for PPM images. The file must consist entirely of integer values. The first integer should be hardcoded to 1297305413. The width and height of the image should be next, followed by the ARGB value of each pixel one row at a time starting in the top left corner of the image.

Recall that the PPM file format looks like this:

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

The corresponding .msoe file would consist of the following integers: 1297305413, 2, 3, -1, -1, -16777216, -65536, -16711936, and -16776961.

Additional Functionality

You must add buttons for the following additional transformations (and make them functional):

In addition, your program must use a FileChooser to select image files to be read and written.

Exception Handling

If any problems are encountered during the execution of the program, an Alert dialog should be displayed providing a useful error message and the program should continue functioning correctly.

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.