Lab 5: Functional Image Transformer
Overview
In this assignment, you will refactor the handler implementations to make use of a functional programming approach and support other transformations.
The assignment builds on lab 3. Begin by incorporating feeback from your instructor on the first three lab assignments.
COMMIT 9 - Functional Interface
Due at the end of class Tuesday Week 5
Update your code based on feedback from your instructor for labs 1 - 3.
Create and document a functional interface, Transformable
, with one method:
apply(int x, int y, Color color)
— accepts the location and color of a pixel and returns a new (perhaps the same) color.
COMMIT 10 - transformImage()
Implementation
Due at the end of class Wednesday Week 5
In your controller class, implement and document the following method:
transformImage(Image image, Transformable transform)
— returns anImage
that consists of the pixels in the input image after the transform has been applied.
COMMIT 11 - Refactored brighten()
/darken()
handlers
Due at the end of class Wednesday Week 5
Update the brighten()
and darken()
handler methods in your
controller class that applied transformations so that they make use
of the transformImage()
method. When completed, the handler methods
should have loops in them.
COMMIT 12 - Red and Red-Gray transforms
Due at the end of class Thursday Week 5
Add support for the following transformations:
- Red — Converts to a red version of the currently displayed image.
- Red-Gray — Converts the displayed image to a version where the pixels in each odd numbered line are transformed using the Red transformation and the pixels in each even numbered line are transformed using the Grayscale transformation. explanation
COMMIT 13 - Remaining refactoring and two additional transformations
Due at the end of class Thursday Week 5
- Refactor the other handlers from lab 3 to use
transformImage()
- Add two other transformations using your own creativity.
Just For Fun
Ambitious students may wish to:
- Add additional transformations.
- Add support for selecting a portion of the image and only applying the transformation to the user-selected portion of the image.
Acknowledgement
This laboratory assignment, developed by Dr. Chris Taylor.