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);
target.set(x,y,c);
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
- If you request propagation, it does not happen immediately, but should be posted in the next day or so
Loop invariants were discussed in the CSE131R seminar. You are welcome to try this extension even if you are not participating in the seminar. However, you must agree to the following:Consider the following code:
- You will meet with the instructor as indicated in the steps below.
- Those meetings will take place in office hours during the semester, or during times otherwise arranged with the instructor.
- Your work on this extension must be complete before the last day of class.
int ans = 0;
int i = a;
while (__________________________ ) { // fill in the loop predicate
i = i - b
ans = ans + 1
}
// ans is now a/b
The code is supposed to compute ans as the int result of
dividing a by b.
You should show your loop invariant to the instructor before proceeding, to be sure that you have a proper loop invariant
Check this with the instructor too.
To be cleared for credit, show your final work to the instructor. Be sure your written work clearly bears your name, your WUSTL key, and your student ID.You will be asked to explain steps of your proof, so you better understand what you write if you want to get credit for it.
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
- If you request propagation, it does not happen immediately, but should be posted in the next day or so