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.
Assignment
The assignment builds on lab 3. Begin by incorporating feeback from your instructor on the first three lab assignments.
Functional Interface
Create 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.
Image Transformation
In your controller class, implement 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.
Update the handler methods in your controller class that applied transformations
so that they make use of the transformImage()
method. When completed, none of
the handler methods should have loops in them.
Additonal Transformations
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
- Two additional 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.
See your professor's instructions for details on submission guidelines and due dates.