ns 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 inte

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Part II: 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: 
(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 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education