Skip to content

techarenz/Year-11-CS-Unit-9-2D-Arrays-Lab-Image-Manipulation

Repository files navigation

Year-11-CS-Unit-8-2D-Arrays-Lab-Image-Manipulation

This lab includes two packages within the src folder: code and image. If you open the code package, you will see a single class called ImageManipulation. This is the only class that you will be writing code in. If you open the image package, you will see four classes within it: APImage, ImageFileFilter, ImagePanel, and Pixel. The only two classes that you will directly use within your program are APImage and Pixel. The APImage class represents an image as a two-dimensional grid of Pixel objects. You will use the constructors and methods in the APImage class and Pixel class in order to complete this lab. The methods for the APImage and Pixel class are listed below.

APImage class

APImage CONSTRUCTORS WHAT IT DOES
APImage() Creates an image from a file dialog selection, or creates a blank, 200 by 200, black image if the user cancels the dialog.
APImage (String filename) Creates an image from the given file; throws an exception if the file does not exist or the file is not in JPEG format.
APImage (int width, int height) Creates a blank image of the given width and height, with a color of black.
APImage METHODS WHAT IT DOES
int getWidth() Returns the images width in pixels
int getHeight() Returns the images height in pixels
Pixel getPixel(int x, int y) Returns the pixel at the given position, where x is the column and y is the row
void setPixel(int x, int y, Pixel p) Resets the pixel at the given position, where x is the column and y is the row
void draw() Makes the image’s window visible and draws the image in it
APImage clone() Returns a new instance of APImage that is a copy of this image
String toString() Returns the string representation of the image containing the information (filename, width, and height)

Pixel class

Pixel CONSTRUCTOR WHAT IT DOES
Pixel(int red, int green, int blue) Creates a pixel with the given RGB values
Pixel METHOD WHAT IT DOES
int getRed() Returns the pixel’s red value
int getGreen() Returns the pixel’s green value
int getBlue() Returns the pixel’s blue value
void setRed(int red) Resets the pixel’s red value to red
void setGreen(int green) Resets the pixel’s green value to green
void setBlue(int blue) Resets the pixel’s blue value to blue
Pixel clone() Returns a copy of this pixel
String toString() Returns the string representation of the pixel (red, green, and blue values)

There are six challenges in this lab (challenge 0, challenge 1, challenge 2, challenge 3, challenge 4, and challenge 5). To complete this lab, you will need to complete challenges 0, 1, 2, 3, 4 and 5. Each challenge involves manipulating an image. The image that you will be manipulating is located in your project and is called cyberpunk2077.jpg.

Below are examples of what your output should look like after calling each method.

Challenge 0:

Screen Shot 2023-03-07 at 3 58 18 PM

Challenge 1:

Screen Shot 2023-03-07 at 3 48 09 PM

Challenge 2:

Screen Shot 2023-03-07 at 3 50 15 PM

Challenge 3 (threshold 20):

Screen Shot 2023-03-07 at 3 49 41 PM

Challenge 4:

Screen Shot 2023-03-07 at 4 14 01 PM

Challenge 5:

Screen Shot 2023-03-07 at 3 48 36 PM

As always, good luck, have fun! =)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages