RU beehive logo ITEC dept promo banner
ITEC 120
2008spring
ibarland,
jdymacek

homeinfoarchiveexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs

lab14a
home photoshopping network
arrays of pixels

formatting tip: See EStyle, for a (beta) BLueJ plug-in which formats your code. Read the short "Basics" section on that page, for instructions. (EStyle is not installed on the lab machines.)

On computers, images are stored as two-dimensional arrays of colors (“pixels”).

Effects

Choose some effects from the following list, and implement them!

  1. Make method filterPurple which keeps the red and blue components of an image, but sets the green component of each pixel to zero.
  2. Make method invert, similar to filterRed, which complements each component: a color of red=0,green=10,blue=254 would be replaced with a color of red=255,green=245,blue=1.
  3. Make method toBlackAndWhite, which replaces each pixel with the average of the three components. That is, a color of red=0,green=10,blue=80 would be replaced with a color of red=30,green=30,blue=30.
  4. Write a method fadeLeftToRight which leaves the left column untouched, the middle column halfway faded to 0, and the rightmost column entirely black, in a continuous fashion.
  5. Make method jailbar, similar to filterRed, which puts black vertical stripes over the image.

    Hint:

  6. Take any two other effects you've written, and make a method which applies both of them. (Does the order matter? That is, if you filterRed and then convert to black and white, is that the same as converting to black and white and then filtering out the red?)
  7. Write a method filterRight which is like FilterRed except that it only filters the right half (or, the bottom half) of the image.
  8. Make method mirrorLR, which flips a picture left-to-right.
  9. Make a method reflectVerticleMiddle, which leaves the left-half of the image intact, but makes the right half a reflection of the left.
  10. Write a method which adds colorful diagonal slashes at random.
  11. Write blocky, which replaces each 3×3 group of pixels with a single color (the average of the original nine).
    For a further challenge, generalize this to making n×n blocks, where n is a parameter.
  12. Make method blur, which replaces each pixel with the average of the pixels adjacent to it.
    (Why is this more difficult than the previous version?)
  13. Make method edgy, which replaces each pixel with the difference between it and some neighboring pixels. That way, edges (which have a big difference from nearby pixels) will be bright, while large areas of the similar brightness (like a bright sky) will be dark.
    (You can first make the image black-and-white, or you can treat each component independently.)
  14. Try writing code to sharpen an image. (This can be difficult. Don't attempt this until you have written edgy.)
  15. Red-eye reduction (more difficult).
    First, by hand, find some pictures that have red-eye in them, and try to detect what RGB values the eyes have. Then write a filter to try to detect and ameliorate such colors in actual photographs.
    (A professional application might even try to detect circles in the input image, but that's a lot tougher.)
  16. Write a method which applies one of your effects just to a circle in the middle of the picture (with, say, a radius of 20 pixels).
    Hint: As before, still call the pixel-changing method on every single location, but have that method only do its work if it is within 20 pixels of the image's center.
  17. See if you can find on the web, how to make an effect replicating sepia (old-timey) photographs, and implement that.
  18. Surprise me!

For each of the above effects, it's interesting to note:

The answers of course vary for the different choices of effects.

homeinfoarchiveexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs


©2008, Ian Barland, Radford University
Last modified 2008.Apr.22 (Tue)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme