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. Note that assignments A and B are team assignments, and that assignment C is a team assignment. A description of which methods are part of which assignment is at the bottom of this web page.
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/dmusican
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
IOException
public 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" is a team assignment. It consists of getting the
constructor, show
methods, scale
,
crop
, and gray
methods 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
circleCrop
, blur
, and dither
working, and is due Monday, 2/14, by 11:59 PM. Submit all of your work
(which includes assignment "A") in a directory called image2b
.
overlay
working, and
should be done individually. For this individual assignment,
you may consult with others, trade ideas, and obtain help; but the
code that you write should be your own. Submit your work (which
includes assignments "A" and "B" from your teamwork) in a directory
called image2c
.
Good luck, and have fun.