CSIS 230 Programming Assignment #3


ImageLab

Background

ImageLab, written in Java, is a platform for writing image filtering and manipulation objects. The ImageLab core builds and displays a GUI with menu items to open and save image files. It also has a menu of available filters that can be applied to images. The GUI creates the filter menu dynamically when ImageLab starts up. Without changing ImageLab, you can create your own filters and have them listed in the filter menu.

Documentation on using the supplied ImageLab files can be found here.

The ImageLab classes provide methods that input and display images. You can then write image filters that modify these images.

ImageLab starts by creating menu items for each available filter and instantiating the filter objects. These filter objects are classes that implement the ImageFilter interface. When the user chooses an image by clicking on the open menu item, ImageLab opens and displays the image. This image is then available for filtering. When the user chooses a specific filter from the filters menu, that filter is applied to the image. To make a new filter available, you must have their filter class implement the ImageFilter interface and you must store the .class file in the filters directory.

ImageFilter interface

All filters, developed as ImageLab plug-ins, must implement the ImageFilter interface. The ImageFilter Interface defines three methods.
  1. public void filter(ImgProvider ip)
    The filter method is called by ImageLab when the corresponding menu item is chosen. ImageLab passes in an ImgProvider object (described below) that is responsible for the current image. The ImgProvider object can supply the image in color or in black and white. It stores the image in RGBA format. The filter method, after it has manipulated the object, creates a new ImgProvider object to store the modified image. This ImgProvider object can then be asked to display the image with a title passed in by the ImageFilter object.

  2. The second method defined in the ImageFilter interface is:
    public ImgProvider getImgProvider();
    This method returns the filtered image to the caller. One time this call occurs is when the user chooses save from the file menu. ImageLab, acting as the menu item's ActionListener, retrieves the ImgProvider object from the filter and stores the image in a file.

  3. The final method defined in the ImageFilter interface is:
    public String getMenuLabel();
    This method returns the String to be used as this filter's menu label. When building the filters menu, ImageLab calls getMenuLabel() for each available filter.

ImgProvider

Each object from the ImgProvider class is responsible for one image. ImgProvider stores the information for each of the four channels (red, green, blue, and alpha) in individual two-dimensional arrays. An ImgProvider object has methods to return any of the four channels and can also return a two-dimensional array holding a gray-scale representation of the image. In addition, ImgProvider supplies methods to read, write and display images.


Diagram

The Assignment:

  1. Write a monochrome filter to change an image to its negative (every value in the array will be changed to (255 - the old value)).
  2. Write a color filter to enhance the blue in the image. Create a new image that has the same red, green, and alpha values as the original image and moves each blue value half way to 255.
  3. Be creative. Write an interesting filter of your choice.

Implementation Detail

  1. When writing a filter you should indicate that the filter is a member of the filter package by placing the line:
    package filters; at the top of the .java file.
  2. So your filter can find the ImageFilter interface, you should put the line:
    import imagelab.*; as the second line in the file.
  3. To compile your filter (assume its called MyFilter.java), go to the parent directory (the directory that has imagelab and filters as subdirectories) and type:
    javac filters/MyFilter.java
  4. To run imageLab, you should be in the same directory and type:
    java imagelab/imageLab

Sample Filters

What to hand in:

Hand in a printout of your .java file and email me the .java files so I can run them.

Due date:

The program is due at the start of class on Wednesday, January 26, 2005