Meetings

MWF 2:00-2:50


ASSIGNMENT 1
FILES


DATES
OUT ON MON SEP 10
DUE ON FRI SEP 21

Assignment 1: Pixel Processing Operations


The goal of this assignment is to implement several linear and nonlinear image filters.

DATES

The assignment is out on Monday, September 10, 2012, and it is due on Friday, September 21, 2012.

ASSIGNMENT FILES

Download the zip file ENGN1610-2012-A1.zip containing all the Assignment 1 files. Unzip it to a location of your choice. You should have now a directory named assignment1 containing the following six files

and the following two subdirectories The Makefile is used to automate the compilation process. If you have the make.exe utility installed in your computer, just run it in the assignment1 directory. Otherwise, you can run the following command at a command prompt in the same directory If the compilation runs without errors, you should find the following two new files in the same directory These are compiled Java bytecode files. The JImgShop program requires these two files and the zip file JImgShopA1.zip to run. The zip file JImgShopA1.zip contains the rest of the Java bytecode files that the JImgShop program requires to run.

In a windows machine you can run the JImgShop program by double clicking on the shortcut JImgShopA1.lnk. Otherwise, type the following command at a command promp.

To speed-up the process you can create a script file to run the previous command.

In a Mac you can run the JImgShop program from the command line using the script JImgShopA1.bash, or by typing the following command at a command promp.

The file JImgPanelPixelOps.java contains the implementation of the graphical user interface associated with this assignment. You don't need to modify this file unless you want to modify the design of the GUI.

The file ImgPixelOps.java contains the implementation of the class ImgPixelOps, which is designed to isolate the Pixel Processing Operations that you need to implement from the rest of the program. The class ImgPixelOps comprises the following public methods

which you need to implement. In fact convertToGray is already implemented as an example.

menu

THE Img CLASS

In the subdirectory docs you will find a file named

which describes the public interface to the Img class. The following three class methods will probably be all you need to complete this assignment

This class is used to represent a 32 bits per pixel image of getWidth() columns and getHeight() rows. The image data is stored in a linear array returned by the getPixel() method. The convertToGray() method of the class ImgPixelOps shows how to access individual pixels from this array, and how to extract the alpha, red, gree, and blue components.

THE VecFloat CLASS

This class is used as an input parameter for the method applyPwlMap to represent a piecewice linear function from [0,1] into [0,1]. This class is a container for a variable length array of float variables. In the subdirectory docs you will also find a file named

which describes the public interface to the VecFloat class.

The following three class methods will probably be all you need to complete this assignment where size() provides the length of the array, and the elements of the array are accessed with the method get(int i). In the last case you have to make sure that the argument belongs to the valid range.

THE ImgPixelOps CLASS

For this assignment you need to complete the implementation of this class.

public Img convertToGray()

This method is fully implemented as an example.

public Img convertToRed()

You need to make each pixel red by setting the green and blue components to zero.

public Img convertToGreen()

You need to make each pixel green by setting the red and blue components to zero.

public Img convertToBlue()

You need to make each pixel blue by setting the red and green components to zero.

public Img threshold(int tMode, int tTest, int tSet, int value)

You need to test the image component specified by the tTest component of the image against the threshold value, and modify the pixel value component specified by the tSet variable. The variable tMod specifies what kind of comparison to make. The details are provided as comments in the provided ImgPixelOps.java file.

public int[] histogramCompute(int nBits, int channel)

You need to compute a histogram of length 1< for the image component specified by the channel variable. The variable nBits is guaranteed to be in the range [1:8]. You need to use to nBits most significant bits of the desired channel to compute the histogram.

public Img histogramEqualize(int nBits, int channel)

You need to histogram equalize the image component specified by the channel variable. If the RGB component is specified, then you need to histogram equalize the red green, and bluee components independently of each other.

public Img applyPwlMap(VecFloat pwlMap, int channel)

You need to map the image component specified by the channel variable onto itself, using the piecewise linear function specified in the pwlMap variable. The piecewise linear function is specified by nKeys = pwlMap.size()/2 (key,value) pairs, which can be accessed as follows

  • float key = pwlMap.get(2*i );
  • float value = pwlMap.get(2*i+1);
where the variable i is in the range [0:nKeys-1]. The keys are guaranteed to be nondecreasing and to span the interval [0,1]. the values are guaranteed to belong to the interval [0,1]. Both have to be scaled to the component range [0:255].

WHAT TO SUBMIT

You need to submit your edited file ImgPixelOps.java. Make sure that it is well commented out. Explain all your choices in the comments. If you were not able to make somethig work, explain the problems here. If you modify the user interface, then you also need to submit your edited JImgPanelPixelOps.java file. If you need to explain things with formulas, you can also send us a document. Create a zip file named ENGN1610-A1-NAME.zip and send it to the instructor as an attachment, where NAME is your last name.