For this assignment, you will be creating a class to hold data that respresents an image. You
will also be writing several methods to manipulate that data, called transformations.
These transformations include cropping, scaling, mirroring, and translating the image.
You may recall that an image can be represented as a 2D array of data points that each hold a value corresponding to brightness/color. Each of these data points is referred to as a pixel. For the standard color images used in this assignment, each pixel consists of a single integer. In the coordinate-space of the image, the pixel at location (0,0) is at the top left corner of the image. The pixel at location (width-1, height-1) is at the bottom right of the image, as shown in the 400x300 image on the right. I have provided PictureDisplay.java to aid in testing your implementation. Download the java file to your COMP110 directory in JGrasp to get started. When you have filled out the methods below, you can show the GUI by compiling and running PictureDisplay.java. The PictureDisplay class will try to access a file called "sample.jpg" in your COMP110 directory. So, place the image you want to work with into that folder and name it appropriately. Here are some sample images: sample.jpg, sample2.jpg, sample3.jpg, sample4.jpg, mousemri.jpg. |
|
|
-> Crop with parameters x=1, y=1, width=2, height=3 -> |
|
Original |
Creating a rectangle to crop |
Cropped |
|
-> Translated up two and right one pixel -> |
|
Original |
Translated Up and Right |
Translated Back to Original Location (data loss) |
|
-> Mirrored Horizontally -> |
|
Original |
Horizontal Flip |
Vertical Flip |
Both Flipped |
|
-> Scaled up by two -> |
|
Original |
Scale Up |
|
-> Discard certain pixels -> |
|
-> Scaled down by two -> |
|
Original |
Scale Down |
|
-> Scale Down -> |
|
-> Scale Up -> |
|
Original |
Scaled Down then Up |