CS-171
Program 4: A Picture Collage
Objective
The objectives of this assignment include the following:
-
Understanding the multiple coordinate systems involved in picture to picture
translations
-
Effectively using nested loops to control transformations in limited pixel
ranges
- To both
understand and to translate into Java programming code many common
transformations performed on two dimensional images
- To use
all of the above to create an interesting picture.
Assignment
For this assignment you will be creating a collage of images.
You should choose your images and composition to reflect the interest that you
have so that your collage tells us something about who you are. You will be
creating a variety of image manipulation routines that will be needed to create
your collage. Below is an example collage that was created by Dr. Kretchmar from
the CS department. His particular interests include running marathons and
cycling.

Requirements
The requirements for this assignment can be partitioned broadly into (i) the
base requirements (including following the instructions faithfully), (ii) a few
required transformations, and (iii) a set of optional transformations.
Points are awarded in each category.
Base Requirements
Core Transformations
-
(15pts) You must use a
scaling routine at least once.
-
(15pts) You must use a
cropping routine at least once.
- (15pts) You obviously
must use an overlay routine to place the images on the collage.
For all of your image
manipulation routines, the method should create and ultimately return a new Picture instance that contains the specified
changes so that the original image is left unchanged. (This is the design
choice we have been making consistently in class.).
Note that the above requirements will earn 70 points on this
assignment. You have ample opportunity to earn additional points as described
below:
Elective Transformations
- (5 pts) Convert your posterize and rotate colors applications into corresponding posterize() and rotateColors() methods in the Picture class. Think about useful parameters for these methods that may make them more general (hint: if you created multiple versions of the Posterize and RotateColors applications, ask yourself if the use of parameters could unify the differences into single method).
- (10 pts) Write a
cropping routine that extracts a circle instead of a rectangle.
- (10 pts for the set of all three) Write routines to rotate the image by 90, 180, and 270 degrees.
- (5 pts) Generalize your
circle cropping routine to extract an ellipse (oval). Note: These are five additional
points plus you must also do the circle routine.
- (5 pts) Write a second
overlay routine that considers ”pure black” as transparent.
- (10 pts) Write a routine to rotate an image through an arbitrary angle between 0 and 360 degrees.
- (10 pts) Do you remember
what you look like in those ”fun house” carnival mirrors that distort your
image? Write a routine to perform these fun house mirror distortions.
- (? pts) Do you have
other creative ideas? Ask the instructor and receive additional bonus points
for some other image manipulation routine.
Details:
- Scale: Provide a scaling factor as a double. Multiply the dimensions by this factor to increase/decrease the height and width of the object. Expand or contract the pixels to create a new copy of the original image. Name your method scale.
- Crop:
Cropping is the act of removing a portion of an image. You need to specify the
upper/left coordinates of the rectangular region to extract along with the width and height of the rectangular region to extract. Return a new image of
the appropriate dimensions that contains only the cropped region. Name your
routine crop. Gracefully handle the case where the cropped region extends beyond the borders of the original image.
- Overlay:
Place one image overtop of another. You should provide the (x,y) coordinates to
specify the upper/left corner of the overlay position. If the overlain image
extends beyond the boundaries of the underlying image, then ignore that portion
of the overlain image and copy as much as is possible. Name your method
overlay.
- Circle Crop: Obviously you must create a rectangualr (square) image, but extract only a circular portion of the original image and make the outer boundaries of the square pure black (so it works especially well with a transparent overlay described below). Specify the center (x,y) and radius of the cropping. Name your method cropCircle. Handle the case where the circle extends the boundaries of the original image.
- Transparent
Overlay: Same as an overlay except that any pure black areas in the
overlaying image ”bleed through” and pick up the underlying image below. Name
your method transparentOverlay.
- Ellipse Crop:
Remember an ellipse? Two centers and a constant sum of distances? This
allows you to do oval croppings. Name your method
cropEllipse.
- Rotation1:
Rotate an image 90, 180, and 270 degrees clockwise. Name your methods
rotate90, rotate180, and rotate270.
- Rotation2: Specify the angle of rotation (in degrees) between 0 and 360 (actually allow any arbitrary angle including negative angles). Rotate the image counter clockwise in this many degrees. Name your method rotate.
- Carnival Mirror: Mirrors either distort horizontally or
vertically but usually not both. So you can choose one or implement both.
Consider the horizontal distortion: the vertical distances are all left
unchanged. But the horizontal features are either expanded or compressed from
the mid axis running vertically through the image. You can use a sine function
to nicely imitate this gradual compression/expansion. Name your method
carnivalMirror.
- Out of
bounds?: Many of these routines will create images that exceed the
dimensions of the source image. If you need to put a pixel out of bounds, then
obviously just ignore it (this part of the image will be omitted).
- Others: If
you create your own image manipulation routines, then be sure to comment them
extensively so that we know how to use them and what they are supposed to do.