CompSci 100e: Program Design & Analysis II(Fall 2009) | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
Pixmap Assignment
BackgroundImages are stored by computers in a variety of formats, such as gif, jpg, tiff, and png. These formats differ in how faithfully they represent the original picture, how well they can be compressed to reduce the space each image takes up, or how well they can be copied from on type of computer to another. However, no matter what format the image is stored in, it can always be represented of as a mapping of (x, y) pixel position to a color (the range of colors may be restricted to values of grey or just black and white). Thus, for the remainder of this project, we will refer to all formats of digital images as pixmaps.This programming project involves manipulating pixmaps. Your program will be able to read in gif, jpg, and png image formats, and perform several operations on these images including invert, reflect, and expand.
Classes To Reviewjava.awt.ColorThis class represents the Color of a pixel as three values ranging from 0 to
255, one each for the level of red, green, and blue that combined to create the
color you see on the computer screen. For the purposes of this program, you
need to understand how to construct a Color, but
you don't really need to understand the internal workings of the class. For more
information about why colors are represented using combinations of red, green,
and blue, see this reference
online. PixmapThis class represents an image, i.e., a 2D-grid of pixels. A black-and-white image can be represented as a 2-dimensional grid of 0/1 pixels. Gray-scale images can be represented using multi-valued pixels. For example, numbers from 0 to 255 can represent different shades of gray. Color images are represented by pixels in which each pixel has three color values: a red value, a green value and a blue value. For example, three numbers from 0 to 255 can represent the different shades of the red, green and blue colors. For black-and-white images, a bitmap is a 2-D grid of 0's and 1's, where a 0 corresponds to white and a 1 corresponds to black. For example, the following is a bitmap which represents a 9x8 black-and-white picture of a `<' sign. The bitmap of 0's and 1's on the left is as an image on the right (enlarged eight times).
For gray-scale images, a bitmap is a 2-D grid of numbers from 0 to 255 representing the shades of gray. The value 255 is white, and the value 0 is black. For example, the gray-scale bitmap below is of size 4x6 and the pixels get a little lighter as the row numbers increase and a lot lighter as the column numbers increase. The last column is much different from the previous columns as the graphic shows.
For color images, a bitmap is a 2-D grid of numbers from 0 to 255, with three numbers representing a pixel. For example, the color bitmap below shows the 3x6 image displayed on the right. Each row has two pixels of red represented by the three numbers 248 0 0 followed by two pixels of green represented by the three numbers 0 252 0, followed by two pixels of yellow represented by the three numbers 248 252 0.
A Pixmap object can be used to access or set the color of an individual pixels and to access or set the total size of the image. Methods that you will use include:
Note, you can change the image displayed on the screen only by calling one of the last two methods described above (the ones that start with set). NegativeThis class is an example of a completed Pixmap Command that determines the negative a Pixmap in a straightforward manner, by subtracting each color in the image from the brightest possible color, white. For example, in a black-and-white bitmap where each bit must be inverted: 0's are changed to 1's and vice versa. The images below are inverted versions of each other. 0 0 0 0 0 1 1 0 1 1 1 1 1 0 0 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 0 0 1 In a color pixmap, the same principle is used: each value (red, green, and blue) is subtracted from its highest possible level, 255. MainYou can execute the Pixmap application by running the class Main. The Open button allows you to browse your file system and load images. The other buttons are bound to the various image manipulation commands. Initially, only Reverse Colors is functional. You will complete the code to make the Resize, Mirror Vertically, Mirror Horizontally, Blur and Sharpen commands functional. Code you will write
Extra CreditMake sure your README.txt file notes any extra credit you attempt. This assignment is worth 34 points.
Submit your project as pixmap, using the Ambient menu within Eclipse. Always be sure to submit all java files, even if you did not modify them. You must also submit a README.txt too. See the assignment page for details on the README. |
||||||||||||||||||||||||
| Last updated Thu Jan 29 7:13:15 EST 2009 | ||||||||||||||||||||||||