0% found this document useful (0 votes)
9 views

Lecture - 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lecture - 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

CSE4203: Computer Graphics

Lecture – 2
Raster Graphics

11
Outline
● Raster and Raster Images
● Image Compression
● Display Devices
● Pixel Values
● RGB Color
● Alpha Compositing

22
Raster (1/1)
• Most computer graphics
images are presented on
raster display.
• i.e. television
– has rectangular array of small
light-emitting pixels
• individually set to different colors
to create desired image.

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/
Image source: https://commons.wikimedia.org/wiki/File:Bresenham_line.png

Image Source: Internet 3


Storing Images (1/2)
• Raster Image:
– used to store and process images, as rasters
are common in devices
• simply a 2D array
• stores the pixel value
foreach pixel
• usually a color stored as
three numbers (r, g, b)

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/
Image source: https://desktop.arcgis.com/en/arcmap/10.3/manage-data/raster-and-images/what-is-raster-data.htm

Image Source: Internet 4


Storing Images (2/2)
• Raster Image:
- Considered as device-independent of the
image to be displayed
- Resolution Dependent i.e quality are
measured using number of pixels per unit
such as DPI
- Resizing can result quality degradation
- Common formats are JPEG, PNG, BMP

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/
Image source: https://desktop.arcgis.com/en/arcmap/10.3/manage-data/raster-and-images/what-is-raster-data.htm

Image Source: Internet 5


Image Compression (1/4)
● Image compression is a method used to reduce the
size of images,
● Improves the rendering speed with reduced file
size
● 2 methods of compression:
○ Lossless Compression
○ Lossy Compression

Credit: Lossy vs Lossless Compression: Differences & Advantages | Adobe

6
Image Compression (2/4)
Lossless Compression
● Don’t impact the image quality
● Only removes additional, non-essential data
automatically added by the device used to take the
photo
● No significant reduction in file size
● Lossless Compression algorithms: Run-length
encoding, Huffman coding
● Lossless formats are .RAW, .BMP, .GIF, and .PNG
Credit: Lossy vs Lossless Compression: Differences & Advantages | Adobe

7
How Run-Length Encoding (RLE) Works

Credit: https://www.youtube.com/watch?v=cAAeSn8_aCU&ab_channel=MizComputing
Image Compression (3/4)
Lossy Compression
● Reduces the file size considerably by removing
image data
● Quality might degrade
● This process is irreversible - can’t get back to the
original file
● Common algorithms - discrete wavelet transform,
fractal compression, transform encryption etc.
● Lossy format; JPEG, MPEG, AVC
Credit: Lossy vs Lossless Compression: Differences & Advantages | Adobe

8
Image Compression (4/4)

Image Source: Internet 9


Display Devices (1/1)
• Transmissive Displays:
– require a light source to illuminate them
– backlight behind the array
• i.e. in a projector, a lamp emits light projected onto the
screen after passing through the array.
• Emissive Display:
– it is its own light source.

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

10
Emissive Displays (1/2)
• Emissive Displays:
• Example: light-emitting diode (LED)
– Each pixel is composed of one or more LEDs
(semiconductor devices)
• emit light with intensity ↔ electrical current passing through them

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

11
Emissive Displays (2/2)
• Sub-pixel:
―Pixels divided into three
independently controlled sub-
pixels (R, G, B)
• each with own LED
(different materials)
• emit light of different colors

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

12
Transmissive Displays (1/3)
• Transmissive Displays:
• Example: light
crystal display (LCD)

– Molecular structure of
liquid crystal rotates the
polarization of light that
passes through it
– LCDs also have sub-pixels.

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

13
Transmissive Displays (2/3)
• Degree of rotation ↔ applied voltage

OFF state

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

14
Transmissive Displays (2/3)
• Degree of rotation ↔ applied voltage

ON state

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

15
Transmissive Displays (3/3)

youtu.be/k7xGQKpQAWw?t=77

16
Pixel Values (1/1)
• Coordinate system for raster screen:
– Convention:

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

17
RGB Color (1/1)
black = (0, 0, 0), red = (1, 0, 0), green = (0, 1, 0),
blue = (0, 0, 1), yellow = (1, 1, 0), magenta = (1, 0, 1),
cyan = (0, 1, 1), white = (1, 1, 1)

Image Source: https://www.geeksforgeeks.org/computer-graphics-the-rgb-color-model/

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

18
Alpha Compositing (1/3)
• Partially overwriting the contents of a pixel.
– Where we have a background and want to insert a
foreground image over it.
• Transparent
• Opaque (not transparent)
• Partially Transparent

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/
Image source: http://www.graphicalweb.org/2005/papers/abstractsvgopen/index.html

14 Image Source: Internet 19


Alpha Compositing (2/3)
• foreground and background must be blended.
c = αcf + (1 − α)cb
• α = Fraction of the pixel covered by the
foreground layer

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/
Image source: http://www.graphicalweb.org/2005/papers/abstractsvgopen/index.html

20
Alpha Compositing (3/3)
• Alpha Mask:
- The α values for all the pixels is stored in a
separate gray scale image.

Credit: Fundamentals of Computer Graphics 3rd Edition by Peter Shirley, Steve Marschner | http://www.cs.cornell.edu/courses/cs4620/2019fa/

21
What can you do with it? Get a photo with Einstein

Source: http://graphics.cs.cmu.edu/courses/15-463/2007_fall/Lectures/blending.pdf 22
What can you do with it? Horror Photo!!

Source: http://graphics.cs.cmu.edu/courses/15-463/2007_fall/Lectures/blending.pdf 23
Practice Question 1
• Given that, Cf = 1.0, Cb = 0.5 and C = 0.8, where,
Cf , Cb and C are the foreground, background and
composite intensities respectively. Determine
the alpha(α) value to perform alpha compositing.

24
Practice Question 2
Consider an image with resolution of 1500 x 1500. Each pixel in the
image can hold up to 8 bit of data.
a) What is the file size of the image in MB?
b) If the image is compressed with a compression ration of 1.5.
What is the file size of the compressed image?

25
Practice Question 2
Consider an image with resolution of 1500 x 1500. Each pixel in the
image can hold up to 8 bit of data.
a) What is the file size of the image in MB?
Solution:
Total number of pixels in the image = 1500 x 1500 = 2250000
Each pixel can hold 8 bit data.
So, the size of the original image = 2250000 x 8 = 1800,0000 bits
= 18000,000 / 8 = bytes = 2250000 bytes = ?? MB
26
Practice Question 2
Consider an image with resolution of 1500 x 1500. Each pixel in the
image can hold up to 8 bit of data.

b) If the image is compressed with a compression ration of 1.5. What


is the file size of the compressed image?
Solution:
Compression ratio = original image size / compressed image size
Compressed image size = original image size / compression ratio
= 2.25 MB / 1.5 = 1.5 MB

27
Further Reading
● Fundamentals of Computer Graphics, 4th Edition -
Chapter 3
● https://www.adobe.com/uk/creativecloud/photograp
hy/discover/lossy-vs-lossless.html

28
Thank You

29

You might also like