Tasks You must implement the following classes based on the specification provided below. In most part, the visibilities and the types of the variables are not provided; it’s your task to figure out...

1 answer below »
Hello. I have another java assignment I need help with. I posted the document with the screenshots of my assignment below named "javaassignment2.docx. Your help is greatly appreciated. Thank you.


Tasks You must implement the following classes based on the specification provided below. In most part, the visibilities and the types of the variables are not provided; it’s your task to figure out what is the proper visibility and type to use in each case. ImagingApp This is the entry point to your executable application. We want to be able to use a command line argument when we run the application. Execution in the terminal should look like this: java ImagingAppinput_file output_file operation parameters input_file the name of the PGM or PPM file that will be used as input image output_file the name of the PGM or PPM file that will be used as output image operation a string that indicates what imaging operation should be applied on the input image before it is saved as the output image. The following are the possible values: "scale" for scaling the image "crop" for cropping the image "flip" for flipping the image "rotate" for rotating the image "compress" for compressing the image parameters one or more command line arguments that further specify the details of the above operation. The following are the options in each case: scale is followed by one integer. If it’s positive (e.g. 3), the image is magnified that many times (e.g. triples in both dimensions). If it’s negative (e.g. -2), the image is minified that many times (e.g. halves in both dimensions). Example: java ImagingApp file1 file2 scale 4 crop is followed by four integers y x h w where y,x is the origin of the cropped region, h is the height of the cropped region and w is the width of the cropped region. Example: java ImagingApp file1 file2 crop 13 7 8 5 flip is followed by one string. If it’s "horizontal", the image is flipped horizontally, and if it’s "vertical", the image is flipped vertically Example: java ImagingApp file1 file2 flip vertical rotate is followed by one string. If it’s "clockwise", the image is rotated 90 degrees clockwise, and if it’s "counterclockwise", the image is rotated 90 degrees counterclockwise. Example: java ImagingApp file1 file2 rotate clockwise compress is followed by two strings ttt ppp . The first one refers to tile compression, the second one to pixel compression, and there are two possible values for each: yes / no Example: java ImagingApp file1 file2 compress yes no Fields static Image inputImage The input image that is constructed from the contents of the input_file , must be assigned to this field. static Image outputImage The output image that is constructed from operations scale, crop, flip, rotate, must be assigned to this field. static CompressedImage compressedImage The output image that is constructed from operation compress, must be assigned to this field. Methods public static void main(String[] args) All the handling of the command line arguments as well as the validation of the user input, takes place in this method boolean saveImage(Image img, String filename) Saves the img into a PGM/PPM file. Returns false if an error occurs, otherwise true. boolean saveImage(CompressedImage img, String filename) Saves the img into a PGM/PPM file. Returns false if an error occurs, otherwise true. Pixel This class represents a single pixel in an image. Fields value It’s an array that holds the actual value of a pixel. For grayscale images, the array has a size of 1, and for color images the array has a size of 3. You may not add any other fields Methods Pixel(grayvalue) Creates and initializes a grayscale pixel Pixel(red, green, blue) Creates and initializes a color pixel getValue() Getter method that returns the value of the pixel equals(Object other) Indicates whether some other pixel is equal to this one. Note: Method overriding. toString() Returns a string representation of the pixel. For grayscale images, this is simply the numerical value of the pixel. For color images, the representation has the format R123#G88#B255 for a pixel with values 123,88,255 Note: Method overriding. Pixel clone() Creates and returns a copy of this Pixel object. The meaning of "copy" is that, for any Pixel x, the expressions x.clone()!=x and x.clone().equals(x) will both be true. In other words, the clone is a deep copy of the original and, therefore, no memory areas are shared between the original and clone. You may not add any other methods Tasks You must implement the following classes based on the specification provided below. In most part, the visibilities and the types of the variables are not provided; it’s your task to figure out what is the proper visibility and type to use in each case. ImagingApp This is the entry point to your executable application. We want to be able to use a command line argument when we run the application. Execution in the terminal should look like this: java ImagingAppinput_file output_file operation parameters input_file the name of the PGM or PPM file that will be used as input image output_file the name of the PGM or PPM file that will be used as output image operation a string that indicates what imaging operation should be applied on the input image before it is saved as the output image. The following are the possible values: "scale" for scaling the image "crop" for cropping the image "flip" for flipping the image "rotate" for rotating the image "compress" for compressing the image parameters one or more command line arguments that further specify the details of the above operation. The following are the options in each case: scale is followed by one integer. If it’s positive (e.g. 3), the image is magnified that many times (e.g. triples in both dimensions). If it’s negative (e.g. -2), the image is minified that many times (e.g. halves in both dimensions). Example: java ImagingApp file1 file2 scale 4 crop is followed by four integers y x h w where y,x is the origin of the cropped region, h is the height of the cropped region and w is the width of the cropped region. Example: java ImagingApp file1 file2 crop 13 7 8 5 flip is followed by one string. If it’s "horizontal", the image is flipped horizontally, and if it’s "vertical", the image is flipped vertically Example: java ImagingApp file1 file2 flip vertical rotate is followed by one string. If it’s "clockwise", the image is rotated 90 degrees clockwise, and if it’s "counterclockwise", the image is rotated 90 degrees counterclockwise. Example: java ImagingApp file1 file2 rotate clockwise compress is followed by two strings ttt ppp . The first one refers to tile compression, the second one to pixel compression, and there are two possible values for each: yes / no Example: java ImagingApp file1 file2 compress yes no Fields static Image inputImage The input image that is constructed from the contents of the input_file , must be assigned to this field. static Image outputImage The output image that is constructed from operations scale, crop, flip, rotate, must be assigned to this field. static CompressedImage compressedImage The output image that is constructed from operation compress, must be assigned to this field. Methods public static void main(String[] args) All the handling of the command line arguments as well as the validation of the user input, takes place in this method boolean saveImage(Image img, String filename) Saves the img into a PGM/PPM file. Returns false if an error occurs, otherwise true. boolean saveImage(CompressedImage img, String filename) Saves the img into a PGM/PPM file. Returns false if an error occurs, otherwise true. Pixel This class represents a single pixel in an image. Fields value It’s an array that holds the actual value of a pixel. For grayscale images, the array has a size of 1, and for color images the array has a size of 3. You may not add any other fields Methods Pixel(grayvalue) Creates and initializes a grayscale pixel Pixel(red, green, blue) Creates and initializes a color pixel getValue() Getter method that returns the value of the pixel equals(Object other) Indicates whether some other pixel is equal to this one. Note: Method overriding. toString() Returns a string representation of the pixel. For grayscale images, this is simply the numerical value of the pixel. For color images, the representation has the format R123#G88#B255 for a pixel with values 123,88,255 Note: Method overriding. Pixel clone() Creates and returns a copy of this Pixel object. The meaning of "copy" is that, for any Pixel x, the expressions x.clone()!=x and x.clone().equals(x) will both be true. In other words, the clone is a deep copy of the original and, therefore, no memory areas are shared between the original and clone. You may not add any other methods Tile This class represents a square block of 4x4 pixels. The pixels are not stored in a 2D array though, but in a 1D array of size 16 (the ordering of the pixels is row by row from top to bottom and within each row is from left to right). Fields Pixel[] block This 1D array holds the references to the 16 pixels that belong to this tile. You may not use a 2D array instead of a 1D array; you will get zero points in the whole project if you do so. You may not add any other fields Methods Tile() Instantiates block as an empty array of size 16 Pixel getPixel(int y, int x) Returns a single pixel from the tile. The pixel is located at position y,x within the tile (y and x correspond to the row and column of the tile, not of the image) void setPixel(int y, int x, Pixel p) Sets the value of a single pixel in the tile. The pixel is located at position y,x within the tile (y and x correspond to the row and column of the tile, not of the image) equals(Object other) Indicates whether some other tile is equal to this one. All pixels must be equal for the two tiles to be considered equal. Note: Method overriding. toString() Returns a string representation of the Tile as a comma separated string of pixel values. Tile clone() Creates and returns a copy of this Tile object. The meaning of "copy" is that, for any Tile x, the expressions x.clone()!=x and x.clone().equals(x) will both be true. In other words, the clone is a deep copy of the original
Answered 6 days AfterSep 24, 2022

Answer To: Tasks You must implement the following classes based on the specification provided below. In most...

Amit answered on Sep 25 2022
70 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here