|
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
We will:
We have provided a class (documentation and source code). with two helpful static methods:
// int pixels as a literal array, then displayed: int[][] data1; data1 = { {30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, {30, 30, 90, 200, 200, 200, 200, 200, 90, 30}, {30, 30, 200, 0, 0, 0, 0, 0, 200, 30}, {30, 30, 200, 0, 0, 0, 0, 0, 200, 30}, {30, 30, 200, 0, 255, 0, 255, 0, 200, 30}, {30, 30, 200, 0, 255, 0, 255, 0, 200, 30}, {30, 30, 200, 0, 0, 0, 0, 0, 200, 30}, {30, 30, 200, 0, 0, 0, 0, 0, 200, 30}, {30, 30, 200, 90, 0, 0, 0, 90, 200, 30}, {30, 30, 200, 90, 90, 0, 90, 90, 200, 30}, {30, 30, 200, 0, 90, 90, 90, 0, 200, 30}, {30, 30, 200, 0, 0, 0, 0, 0, 200, 30}, {30, 30, 90, 200, 200, 200, 200, 200, 90, 30}, {30, 30, 30, 30, 30, 30, 30, 30, 30, 30} }; Pict.displayPixels( data1 ); |
Task, together:
Write a method which creates a 500x500 array,
then initializes location i,j is initialized to
Task: Now, tweak the above method to try different formulas. (For each one, you're encouraged to predict the result first.)
(i*j)*256/(width*height) |
if ((i*j)%59 == 0) set location i,j to 0 else set location i,j to 255. |
if ((i*j)%60 == 0) set location i,j to 0 else set location i,j to 255. |
Group Task
Write a method which takes any 2-D array of
To add up all the values in the array,
you can either use a helper method (
something like
Your Task
Write a method which takes any 2-D array of
You can either use a helper method
(
Your Task
Write a method
You can either use a helper method
(something like
Choose one effect from the following list, and implement it!
To figure out what you should do,
work a small test case by hand
(say, the 3x4 array
Flip the picture left-to-right.
To do this, you need to think:
where should pixel 0,0 end up?
What about pixel 2,0? or 2,3?
See if you can figure out the general formula for pixel r,c.
(Your formula should involve the array's width and height, in general.)
There are also plenty of other photo effects you could do, instead of the above.
1 Hey, for once integer division is what we want, since we're storing the result back into an int. Note that any number in [0,256), when average with 256, is still in [0,256). That's because (255+256)/2 is 255, by integer division. This will be important below. ↩
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
©2012, Ian Barland, Radford University Last modified 2012.Dec.04 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |