Directions: In the imagetransforms package, modify the provided Transforms Java program to implement the methods as described below. Your methods will use iteration (either while loops or for loops) to operate on the pixels of a picture.
This extension uses the same base code as the filter extension.
There is just one exception: the gradient method produces its output without needing a source. Its only parameter is target.
int width = p.width(); int height = p.height();
Color c = source.get(x,y);
Each of the methods described below is found in the Transforms class.
Look at the code given to you for this example carefully. It is broken into simple steps and the comments help explain why the pixel indexing works.
The left half of the target image should be same as the source, but the right half of the target image should be the mirror of the left half of the source.
Develop an expression for the amount of red and green in each pixel, given the x and y position of that pixel and the width and height of the image:int amountRed = ..... int amountGreen = ....Then set the pixel at (x,y) to a color based on those computations:target.set(x, y, new Color(amountRed, amountGreen, 128));
Note There are other methods in the Transform class, but they are the subject of other extensions. Once you have completed the above work, demo and you are done with this extension.
When you done with this extension, you must be cleared by the TA to receive credit.
- Commit all your work to your repository
- Fill in the form below with the relevant information
- Have a TA check your work
- The TA should check your work and then fill in his or her name
- Click OK while the TA watches