(Needs to write a java program. The imput file that the code will be tested on will be really large, but a code that can work on the provided sample in the picture should work just fine) An image is an array, or a matrix, of pixels (picture elements) arranged in columns and rows. RGB is one of the models used in color pixels. In a color image, each RGB pixel is an integer number which contains the mixture of red, green and blue colors. In this assignment, you will be provided with an image data file, image.dat. The first line in data file contains the height (rows) and width (columns) of the image. The following lines gives the red, green and blue color integer values for each pixel. The following sample.dat is given as an example: (The given example can be seen on the picture down) According to this input file, the image has 4 rows and 2 columns. The pixel at [0][0] has red value 117, green value 117 and blue value 245. Write a Java program that reads from the given input file and creates an RGB image object with the given width and height. Then, it'll read red, green and blue color values for each pixel from data file, and calculate RGB integer value using only bitwise shifting and masking operations. This is how you'll mix the colors and express the color pixel with one single integer. After generating RGB value for each pixel, your program will set the RGB value of each pixel with the computed RGB value. Your program will generate a .png image file as an output. Sample output: sample.png (The sample output can be seen on the picture down)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(Needs to write a java program. The imput file that the code will be tested on will be really large, but a code that can work on the provided sample in the picture should work just fine) 
An image is an array, or a matrix, of pixels (picture elements) arranged in columns and rows. 
RGB is one of the models used in color pixels. In a color image, each RGB pixel is an integer 
number which contains the mixture of red, green and blue colors. 

In this assignment, you will be provided with an image data file, image.dat. The first line in data 
file contains the height (rows) and width (columns) of the image. The following lines gives the 
red, green and blue color integer values for each pixel. 

The following sample.dat is given as an example: 
(The given example can be seen on the picture down)


According to this input file, the image has 4 rows and 2 columns. The pixel at [0][0] has red 
value 117, green value 117 and blue value 245. 

Write a Java program that reads from the given input file and creates an RGB image object with 
the given width and height. Then, it'll read red, green and blue color values for each pixel from 
data file, and calculate RGB integer value using only bitwise shifting and masking operations. 
This is how you'll mix the colors and express the color pixel with one single integer. After 
generating RGB value for each pixel, your program will set the RGB value of each pixel with the 
computed RGB value. Your program will generate a .png image file as an output. 

Sample output: sample.png 
(The sample output can be seen on the picture down)
 


 

 

 


HINTS 

• The following Java statement create an image object with the given height, width and image 
type of RGB 
BufferedImage canvas = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 

• The following Java statement updates the RGB value of the pixel located at row y, and 
column x of the image. 
canvas.setRGB(x, y, rgb); 

• The following Java statement created a .png file(image.png) from a BufferedImage object. 
ImageIO.write(canvas,"PNG",new File("image.png"));

 

Here is an image of what a file might look like and the output.

Page
2
of 5
ZOOM
+
Part Il: Image Representation
An image is an array, or a matrix, of pixels (picture elements) arranged in columns and rows.
RGB is one of the models used in color pixels. In a color image, each RGB pixel is an integer
number which contains the mixture of red, green and blue colors.
In this assignment, you will be provided with an image data file, image.dat. The first line in data
file contains the height (rows) and width (columns) of the image. The following lines gives the
red, green and blue color integer values for each pixel.
The following sample.dat is given as an example:
4 2
01110101,01110101,11110101 01110101,01010111,11110101
01110101,11010101,01010101 11010101,01010101,01010101
11000101,00011101,01110101 01100101,11110111,00100101
11110101,01110101,11010101 11110101,01111101,11110001
According to this input file, the image has 4 rows and 2 columns. The pixel at [0][0] has red
value 117, green value 117 and blue value 245.
Write a Java program that reads from the given input file and creates an RGB image object with
the given width and height. Then, it'll read red, green and blue color values for each pixel from
data file, and calculate RGB integer value using only bitwise shifting and masking operations.
This is how you'll mix the colors and express the color pixel with one single integer. After
generating RGB value for each pixel, your program will set the RGB value of each pixel with the
computed RGB value. Your program will generate a .png image file as an output.
Sample output: sample.png
Transcribed Image Text:Page 2 of 5 ZOOM + Part Il: Image Representation An image is an array, or a matrix, of pixels (picture elements) arranged in columns and rows. RGB is one of the models used in color pixels. In a color image, each RGB pixel is an integer number which contains the mixture of red, green and blue colors. In this assignment, you will be provided with an image data file, image.dat. The first line in data file contains the height (rows) and width (columns) of the image. The following lines gives the red, green and blue color integer values for each pixel. The following sample.dat is given as an example: 4 2 01110101,01110101,11110101 01110101,01010111,11110101 01110101,11010101,01010101 11010101,01010101,01010101 11000101,00011101,01110101 01100101,11110111,00100101 11110101,01110101,11010101 11110101,01111101,11110001 According to this input file, the image has 4 rows and 2 columns. The pixel at [0][0] has red value 117, green value 117 and blue value 245. Write a Java program that reads from the given input file and creates an RGB image object with the given width and height. Then, it'll read red, green and blue color values for each pixel from data file, and calculate RGB integer value using only bitwise shifting and masking operations. This is how you'll mix the colors and express the color pixel with one single integer. After generating RGB value for each pixel, your program will set the RGB value of each pixel with the computed RGB value. Your program will generate a .png image file as an output. Sample output: sample.png
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY