Question: Image Converter: [JAVA] I'm having some difficulties creating an image converter program. Here is my task: Objectives Develop a class from a UML description Use

Image Converter:

[JAVA]

I'm having some difficulties creating an image converter program. Here is my task:

Objectives

Develop a class from a UML description

Use Java API classes to manipulate images

Assignment Task:

We wrote a UML diagram for an ImageConverter class. Let's assume its structure is as follows:

----------------------------------------- ImageConverter ----------------------------------------- - BufferedImage img - String color - String inputFilename ----------------------------------------- +ImageConverter() +readImage(filename : String) : void +toGrayscale() : void +toRed() :void +toGreen() : void +toBlue() : void +writeImage() : void +getPixelRGB(x : int, y : int) : String +toString(): String +classDemo(): void 

Code the ImageConverter class according to the UML diagram.

You will notice that I have added an additional class called classDemo(), this will serve as our little demonstration of inheritance. String is an object in java and all objects inherit from the Object class. In this little method all I am asking for is for you to call the ".getClass()" function on your "String color" variable and just put that in a print statement that's it. The ".getClass()" function is a function all Objects in java have, if you would like to check out all the methods that Objects have here is the Object API.

https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#Object--

Also, have a toString() method that will return a string that says:

The image is now (color). 

You will need to write a driver program to test your class. A template is provided (it is not complete).

Turning in the program

Submit your ImageConverter class by the due date. It will be unit tested. Also submit in class a copy of ImageConverter.java, fully documented and easy to read. As proof of correctness, you may

include color images (make them small to save ink) of each: original, grayscale, red, blue, and green image. OR

include a screenshot of the file system before (only the original file) and after running the program (all five image files).

A Sample ImageConverterTester

import java.util.Scanner; import java.io.IOException; /** * Driver program: Converts a color image into various colors * @author cs108 * */ public class ImageConverterTester { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); ImageConverter ic = new ImageConverter(); int x=30,y=30; // test pixel values String filename = scan.next(); ic.readImage(filename); System.out.println(ic.getPixelRGB(x, y)); ic.toGrayscale(); System.out.println(ic.getPixelRGB(x, y)); ic.writeImage(); // TODO: Re-read in image, convert to Red; repeat for Green and Blue } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!