For this assignment, we will get fancier in our ability to process images. We will now think of an image as a three-dimensional array of pixels: the first dimension corresponds to the rows, the second to the columns, and the third to the color bands.
This assignment will be due in two parts--part A on Friday 2/11 and part B on Wednesday 2/16. See the bottom of this page for details.
We will again use the EasyBufferedImage class, which
gives us some of the basic tools that we need. Make sure to retrieve a
new copy of EasyBufferedImage from the
/Accounts/courses/cs117/ondich directory.
While you're at it, grab a copy of either jackets.jpg or water.jpg, or obtain your own
image instead if you like: you can use your picture from the Carleton
directory or you can take your own picture with a digital camera.
Your mission is to create a class called
ImageMultiProcessor that contains an
EasyBufferedImage object as a private variable. This
class will be similar in structure to the ImageProcessor
class that you wrote for the last assignment, but with a different set
of methods:
public ImageMultiProcessor(String filename) throws
IOExceptionpublic void show(String title)show(String title) method on
your private image.public void show(String title, int x, int
y)show(String title, int x,
int y) method on your private image.public boolean scale(double scaling)scaling is 2, for example, your
image should double in size. Likewise, if scaling is
0.25, your image should be 1/4 the size of the original. If
scaling factor is less than or equal to 0, make no
changes to the image and return false. Otherwise, return
true.public boolean crop(int rowStart, int rowStop,
int colStart, int colStop)rowStart through rowStop and
colStart through colStop. If any of the
parameters are out of range for your image, leave the image unchanged
and return false. Otherwise, return true.
public void gray()EasyBufferedImage, you can
construct a gray image with a 2-dimensional array consisting of rows
and columns. To make your image gray, constuct a new image by
averaging together all the color values for each pixel.public boolean circleCrop(int centerRow, int
centerCol, int radius)centerRow
and centerCol and a radius of radius. Since
the image itself must still be rectangular to fit inside a window,
make the background of the rest of the image white. See example
below. If centerRow, centerCol,
radius, or some combination thereof are invalid, return
false. Otherwise, return true.
public boolean blur(int radius)public boolean dither()Dithering should only be done on gray images, so return false if the image isn't gray already.
public boolean overlay(ImageMultiProcessor
overlayImage, int row, int col)overlayImage onto the image, as in the
example below. If overlayImage can't be placed on the
image (perhaps because it is too large or row or
col are not valid), return false. Otherwise,
return true.
Test your program by writing ImageMultiProcessorTest.java. Check the return values from your methods, and print out text indicating whether or not your methods were successful.
Assignment A consists of getting the
constructor, the show methods, and the crop method
working, and is due on Friday. You and your partner should submit
ImageMultiProcessor and
ImageMultiProcessorTest, along with any associated
images, in a directory called image2a
scale, gray,
circleCrop, blur, dither, and
overlay methods. Submit all of your work
(including the work for assignment "A") in a directory called image2b.
Start early, have fun, and let me know if you need help.