Lab 2: Mean Image Median Displayed

Overview

In this assignment, you will incorporate lab 1 feedback from your instructor (if available), and load and display images in a graphical user interface.

Video introduction for the lab

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

As part of the pre-lab activity you must ensure that you have JavaFX installed on your laptop.

If you are continuing to use the same repository as you used for the first assignment, you’ll need to add the VM options to the run configuration for this project since the run configuration for new projects that you configured following the installation instructions only apply to new projects.

Assignment

In addition to incorporating feedback from your instructor, you must replace the code in the mocked package with appropriate JavaFX code (change the imports to use the javafx.scene.image classes). You must:

Writing an image in PNG or JPG format can be done with the javax.imageio.ImageIO.write() method, and you can use the javafx.embed.swing.SwingFXUtils.fromFXImage() method to get a BufferedImage (that is a RenderedImage). If writing PNG files works but it doesn't work for JPG files, don't worry about it.

Your program must run as a .jar file from the command line and accept the following arguments:

Potentially useful tutorials:

Once the .jar file is created, move it from the out/artifacts/... folder into the project folder (same folder as the README.md file) and rename it lab2.jar.

The program will process the input images to produce the desired output and then save and display the resulting image. For example,

java -jar lab2.jar median images/codeMedian.ppm images/code1.png images/code2.png images/code3.png

will produce codeMedian.ppm in the images folder that is the median of the first three codeX.png images.

You can display an Image in the Scene by placing the Image in a ImageView that is placed in an HBox that then gets added to the Scene.

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:

Acknowledgment

This laboratory assignment, developed by Dr. Chris Taylor.

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