Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to write a UML design document which will be submitted in class at the start of class on the due date. Consult Grayscale.java

image text in transcribed

You are to write a UML design document which will be submitted in class at the start of class on the due date.

Consult Grayscale.java file from which to write a UML diagram for a class called ImageConverter.

The provided Grayscale class is a program that contains the functionality we need. You are to convert it to a concrete class (one that can be instantiated). It should have methods to read an image file from a JPG file (such as, originalFileName.jpg), four conversion methods (one for each: grayscale, red, blue, green), and one to write the altered image to a new file named with the color appended (such as, originalFileNameColor.jpg).

Consider what private data ImageConverter should contain and how to initialize that data. Include any helper (private) methods you may need. You will be graded on how well your UML uses data, naming conventions, UML format, and how well the program is modularized into methods.

You may draw the UML using a computer tool or by hand. Just make sure it is readable and neat. And accurate, of course.

image text in transcribed

image text in transcribed

Introduction Image files are stored in various formats such as JPG, GIF, PNG. An image can be thought of as a m by n matrix where each (xy) holds an encoded color value. The JPG file format for one of these (xy) points (usually called a pixel) is 32-bits. Eight each for transparency, red green, blue components. Transparency Red Green Blue 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 The "RGB" value can be written grouping four bits together to make a value between 0 and F. For example, the above bit value can be written: OXFF339966 and would display a green color Another example, where red, blue, and green components are equalOxFF999999, is a gray color The goal is to convert a JPG image into four different images: grayscale, red, green, and blue. Red is obtained by dropping to zero the green and blue components, blue drops the red and green, and green drops the red and blue. Grayscale takes the average of redgreen, and blue component values and replaces each component with the average. To drop a color, do a bitwise AND (8) setting to 1 all bits you want to keep and to 0 all bits you want to zero out. (Note: the Transparency bits will remain unchanged.) int newRedPixel OxFF339966 & OxEFFFO000; // To extract each r, g, b to find the average , use this formula: int pixel img. getRGB (x, y) ; int trans = (p>>24) 60xff, (p>>16) 60xff; int green = (p>>8) &0xff ; int blue p&Oxff; Java has many packages to deal with I/O including reading and writing image files. There are many classes available, some newer than others. We will import java.awt. image.Buffered Image, and javax. imageio. ImageIO. File f1 = new File (someFilename ); BufferedImage img = ImageIo. read (11 ); // read file File f2 = new File (someotherFilename ); ImageIO. Write (img, 'jpg", f2) ; // write to file Introduction Image files are stored in various formats such as JPG, GIF, PNG. An image can be thought of as a m by n matrix where each (xy) holds an encoded color value. The JPG file format for one of these (xy) points (usually called a pixel) is 32-bits. Eight each for transparency, red green, blue components. Transparency Red Green Blue 1 1 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 The "RGB" value can be written grouping four bits together to make a value between 0 and F. For example, the above bit value can be written: OXFF339966 and would display a green color Another example, where red, blue, and green components are equalOxFF999999, is a gray color The goal is to convert a JPG image into four different images: grayscale, red, green, and blue. Red is obtained by dropping to zero the green and blue components, blue drops the red and green, and green drops the red and blue. Grayscale takes the average of redgreen, and blue component values and replaces each component with the average. To drop a color, do a bitwise AND (8) setting to 1 all bits you want to keep and to 0 all bits you want to zero out. (Note: the Transparency bits will remain unchanged.) int newRedPixel OxFF339966 & OxEFFFO000; // To extract each r, g, b to find the average , use this formula: int pixel img. getRGB (x, y) ; int trans = (p>>24) 60xff, (p>>16) 60xff; int green = (p>>8) &0xff ; int blue p&Oxff; Java has many packages to deal with I/O including reading and writing image files. There are many classes available, some newer than others. We will import java.awt. image.Buffered Image, and javax. imageio. ImageIO. File f1 = new File (someFilename ); BufferedImage img = ImageIo. read (11 ); // read file File f2 = new File (someotherFilename ); ImageIO. Write (img, 'jpg", f2) ; // write to file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions