CS 305J Assignment 10, Color Histograms, two dimensional arrays and objects
| Programming Assignment 10 | This is a pair assignment. You may work with
one other person (You make work with one other person on this assignment
using the pair programming technique.. You may work with anyone in the
class. They do not have to be in the same discussion section as you or the
same partner as on previous assignments. One solution will be turned in for
the pair. Once you start working with one partner on an assignment you may
not switch partners. If you do not wish to work with a partner after
starting on an assignment you must both complete it individually. The intent
here is you work on the assignment together, at the same time, at the same
computer. Do not simply try to work on different parts independently and
then try to put it together. You may choose to work alone if you wish.)
Placed online: November 14 |
||||||||||||||||
| Description | The purposes of this assignment are:
Thanks to M. Dennis Mickunas for use of his DrawingBox class. Background: In this assignment you will be working with images. Images in computers are handled in many different ways. We will be treating images as a 2 dimensional array of ints. A single int contains the color information for the corresponding pixel in the image. So the int at row 0, column 0 corresponds to the upper left pixel in an image.
The color scheme the program will be using is the red-green-blue or RGB
color scheme. In the RGB scheme a color is specified by how much red, green,
and blue light it has. A value of 0 means no light of that color, a value of
255 means maximum intensity for that color. Thus black would be 0-0-0. White
would be 255-255-255. Instead of using 3 ints you will store the color data
for a pixel you will be working with a single int that stores the red,
green, and blue components as a single number. You will
be converting from a single int
with all the information for the amount of red, green, and blue light packed
into that single int to a A color histogram is a representation of a picture created by counting the number of pixels with various intensities in an image. Instead of counting the number of each intensity (which would be 256) the intensities are grouped together in bins. So for example if the bin size is 10 there will be 26 bins (256 / 10 = 25 + 1 partial bin for a total of 26 bins.) Each color component (red, green, and blue) would have 26 bins if the bin size were 10. With a bin size of 10, pixels with red intensities of 0 to 9 would be counted in red bin 0, red intensities of 10 to 19 would counted in red bin 1, red intensities of intensities of 20 to 29 would be counted in red bin 2 and so forth. (For the assignment the bin size has been set to 5 via a constant.) Here is an example of what a color histogram can look like (The bins sizes look very small in this example):
The 2d array representing an image is scanned and for each element in the 2d array (which represents a single pixel) the red, green, and blue intensity are determined and the proper bin is incremented. After counting up all the pixels the bins are normalized to the percentage of pixels in that bin. So every bin will contain a number between 0 and 100. In this assignment you will use a 2d array of doubles to represent the bins and thus the histogram. The 2d array of doubles only has 3 rows for red, green, and blue. the number of columns equals the number of bins. Color histograms are useful because that can be used to compare pictures of different sizes and resolution. One technique to measure how close two images are is to compare their color histograms. How well the images match can be expressed as a match score. The match score is determined by looking at each bin for each color of the two histograms and adding the minimum of the two. (This technique only works if the bin sizes an thus the number of bins are the same.) How to Approach the Assignment:
This assignment is different than past assignments in two ways. First you
will not be completing the entire program from scratch. Instead you will be
completing parts of the program. I provide the shell of the program
and most of the methods to handle input and output as well as the methods
that convert an image file to a 2D array of ints. You will have to look at
the existing code in the
Running the Program:
When you run the main method in When testing the program in is probably best to create a directory with just 3 or 4 jpeg files. You can use your own or ones I provided. After you get the program working try it on a larger set of files. Turn in your completed ImageMatcher.java and ColorHistogram.java files to one persons accounts using the turnin program. |
||||||||||||||||
| Files |
|
||||||||||||||||
| Checklist | Did you remember to:
|