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

01 - Images and Colors

This document is the first lecture on images and colors from a computer graphics course. It introduces some key concepts: - An image is defined as a 2D array of pixels, with each pixel storing a color value. - Color values are typically stored as triples of red, green, and blue integer values. - Common color models like RGB, CMY, HSV are discussed as ways to represent colors. - Framebuffers are introduced as memory arrays that store the visible content of a display window.

Uploaded by

swathi
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)
55 views

01 - Images and Colors

This document is the first lecture on images and colors from a computer graphics course. It introduces some key concepts: - An image is defined as a 2D array of pixels, with each pixel storing a color value. - Color values are typically stored as triples of red, green, and blue integer values. - Common color models like RGB, CMY, HSV are discussed as ways to represent colors. - Framebuffers are introduced as memory arrays that store the visible content of a display window.

Uploaded by

swathi
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/ 22

Lecture #01

Images and Colors


Computer Graphics
Winter term 2019/20

Marc Stamminger
Computer Graphics
• is about the generation of images with computers

• So what is an image in this context?


• A file with extension .jpg, .png or similar ?
• A function mapping colors to a 2D-region ?
• A 2D table of color values ?

Computer Graphics 2019/20 - Images and Colors 2


Computer Graphics
• is about the generation of images with computers

• So what is an image in this context?


• A file with extension .jpg, .png or similar ?
• A function mapping colors to a 2D-region ?
• A 2D table of color values ?

Computer Graphics 2019/20 - Images and Colors 3


Images
• For now, an image is a 2D-array of pixels (Pixel = picture element)
• Each pixel can be
• a bit: black / white
• an integer value (typically 8 bits): grey value
• an integer triple (typically 3x8 bits): color value (red, green and blue)
→ we briefly discuss colors in a minute
• an integer quadruple (typically 4x8 bits): color value with transparency
• float instead of integer: high dynamic range images (HDR images)

w pixels

pixel at (x,y) → buffer[x+w*y]

h pixels
Computer Graphics 2019/20 - Images and Colors 4
Image Files
• Images can be stored in many different file formats
• uncompressed
• compressed
• lossless
• lossy, varying quality
• as movies

Computer Graphics 2019/20 - Images and Colors 5


Image Files
• Example:
• Image size 3888 × 2592
• Raw data: 3888 × 2592 × 3 ≈ 30 MB
• BMP-File: 30 MB
• PNG (compressed, lossless): 13.8 MB
• JPG (good quality): 6 MB
• JPG (low quality): 200 kB

• In a FullHD movie:
• HD-streaming 5 Mbit/s, 25fps:
5𝑀𝑀: 8: 25 = 25 kB !
By Octagon (Own work) [GFDL

• We don’t care about image file formats


(http://www.gnu.org/copyleft/fdl.html) or CC BY 3.0
(http://creativecommons.org/licenses/by/3.0)], via
Wikimedia Commons
in this lecture!

Computer Graphics 2019/20 - Images and Colors 6


Framebuffer
• Memory array storing the visible content of a window on screen
→ size varies with window
• display of windows on screen done by GPU (at least) one framebuffer
→ we don’t care for each window

Computer Graphics 2019/20 - Images and Colors 7


Framebuffer Example
• Directly writing colors to a frame buffer

Computer Graphics 2019/20 - Images and Colors 8


Color Models
• the human eye has tiny light-sensitive sensors in the retina: rods
and three different cones.
• Rods are sensing brightness independent of color
→ they deliver a black&white image
• Cones sense light varying with frequency
• the three types of cones have peak sensitivity at red, green, and blue
frequencies.
• they provide color, but with lower resolution and dynamic range
• Color as perceived by humans is three-dimensional
→ Tristimulus Theory
• Colors are represented as triples of red, green, and blue values

Computer Graphics 2019/20 - Images and Colors 9


Color Models
• There are many ways to define the meaning of these triples
• Technology-driven:
• RGB, CMY, CMYK, YUV, …
• Perception-driven:
• XYZ, HSV, HSB, HSL, Lab, Luv, …
• Standardized:
• XYZ, Lab, …

Computer Graphics 2019/20 - Images and Colors 10


Color Models
• RGB color model
• Red, Green and Blue primaries
• Used (internally) in every monitor
• Additive: adding primitive colors produces white.
• Black = (0,0,0), White = (1,1,1) (=Red+Green+Blue)
• The exact colors of RGB are not defined
Green Yellow
→ colors vary with displays G (0,1,0) (1,1,0)
• RGB is used in framebuffers Greyscale

Cyan White
(0,1,1) (1,1,1)
Black
(0,0,0) R
Red
B (1,0,0)
Blue Magenta
(0,0,1) (1,0,1)

Computer Graphics 2019/20 - Images and Colors 11


Color Models
• CMY color model
• Cyan, Magenta and Yellow primaries
• Used (internally) in hardcopy devices (printers)
• Subtractive (colors subtracted from white background)
→ Adding primary colors produces black.
• Black = (1,1,1), White = (0,0,0)
• Complementary to RGB : C = 1-R, M = 1- G, Y = 1-B
Blue
M Magenta

Greyscale

Red Black
White
C
Cyan
Y
Yellow Green
Computer Graphics 2019/20 - Images and Colors 12
Color Models
• CMYK color model
• Modification of CMY-model
• K for black, additional ‘color’ channel (for saving ink)
• No unique presentation: e.g. (1,1,1,0) and (0,0,0,1)
→ use as much black as possible (it’s cheaper)
• Standard conversion CMY -> CMYK
K = min(C,M,Y) , C = C-K ,
M = M-K , Y = Y-K

Computer Graphics 2019/20 - Images and Colors 13


Color Models
• The RGB/CMY cube

Blue Cyan

https://commons.wikimedia.org/

Magenta wiki/File%3ARGB_Colorcube_Cor
ner_White.png

White

Black
Green

Red Yellow
Computer Graphics 2019/20 - Images and Colors 14
Blue
Color Models
Magenta Cyan
• HSV color model (sometimes HSB)
• More human-oriented color specification,
derived from RGB color model
Red
Green
• Look at RGB color cube along the diagonal
• Along the silhouette, we see the “rainbow” Yellow
colors → color hue, defined as angle
with red = 0°, green = 120° and blue = 240° RGB color cube
• White is at the center, from there to the
boundary the saturation increases
• We only see the brightest colors, darker ones are
inside the cube. The select these, we scale the
visible color by the value hue

saturation

Color hexagone
https://commons.wikimedia.org/wiki/File
%3ARGB_Colorcube_Corner_White.png
Computer Graphics 2019/20 - Images and Colors 15
Color Models
• Geometric model for HSV
• circular cone or cylinder

chroma = saturation

https://commons.wikimedia.org/wiki/File%
3AHSV_color_solid_cone_chroma_gray.png

https://commons.wikimedia.org/wi
ki/File%3AHsl-hsv_models.svg
Computer Graphics 2019/20 - Images and Colors 16
Color Models
• RGB → HSV (cone model)
• 𝑉𝑉 = max 𝑅𝑅, 𝐺𝐺, 𝐵𝐵 = 𝑚𝑚𝑚𝑚𝑚𝑚
𝑚𝑚𝑚𝑚𝑚𝑚−𝑚𝑚𝑚𝑚𝑚𝑚
• 𝑆𝑆 =
𝑚𝑚𝑚𝑚𝑚𝑚
𝐺𝐺−𝐵𝐵
60
𝑚𝑚𝑎𝑎𝑎𝑎−𝑚𝑚𝑚𝑚𝑚𝑚 𝑖𝑖𝑓𝑓 max 𝑅𝑅, 𝐺𝐺, 𝐵𝐵 = 𝑅𝑅
𝐵𝐵−𝑅𝑅
• 𝐻𝐻 = 60 + 120 𝑖𝑖𝑖𝑖 max 𝑅𝑅, 𝐺𝐺, 𝐵𝐵 = 𝐺𝐺
𝑚𝑚𝑚𝑚𝑚𝑚−𝑚𝑚𝑚𝑚𝑚𝑚
𝑅𝑅−𝐺𝐺 𝑖𝑖𝑖𝑖 max 𝑅𝑅, 𝐺𝐺, 𝐵𝐵 = 𝐵𝐵
60 + 240
𝑚𝑚𝑚𝑚𝑚𝑚−𝑚𝑚𝑚𝑚𝑚𝑚

• Color pickers often use HSL, which is a variant of HSV


(see definition here):

Computer Graphics 2019/20 - Images and Colors 17


Color Models
• HSV → RGB (cone model)
• 𝐶𝐶 = 𝑉𝑉 × 𝑆𝑆
𝐻𝐻
• 𝑋𝑋 = 𝐶𝐶 × 1 − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚 −1
60°
• 𝑚𝑚 = 𝑉𝑉 − 𝐶𝐶
𝐶𝐶, 𝑋𝑋, 0 𝑖𝑖𝑓𝑓 0° ≤ 𝐻𝐻 < 60°
𝑋𝑋, 𝐶𝐶, 0 𝑖𝑖𝑓𝑓 60° ≤ 𝐻𝐻 < 120°
′ ′ ′ 0, 𝐶𝐶, 𝑋𝑋 𝑖𝑖𝑖𝑖 120° ≤ 𝐻𝐻 < 180°
• R , ,B =
0, 𝑋𝑋, 𝐶𝐶 𝑖𝑖𝑖𝑖 180° ≤ 𝐻𝐻 < 240°
𝑋𝑋, 0, 𝐶𝐶 𝑖𝑖𝑖𝑖 240° ≤ 𝐻𝐻 < 300°
𝐶𝐶, 0, 𝑋𝑋 𝑖𝑖𝑖𝑖 300° ≤ 𝐻𝐻 < 360°
• 𝑅𝑅, 𝐺𝐺, 𝐵𝐵 = 𝑅𝑅′ + 𝑚𝑚 × 255, 𝐺𝐺 ′ + 𝑚𝑚 × 255, 𝐵𝐵′ + 𝑚𝑚 × 255

Computer Graphics 2019/20 - Images and Colors 18


Color Models
• Windows color picker using HSL

hue

saturation

HSL
Computer Graphics 2019/20 - Images and Colors 19
Color Models

https://xkcd.com/1882/
Computer Graphics 2019/20 - Images and Colors 20
In This Lecture We Learn How To
• ... rasterize simple primitives
• ... transform these primitives
• … in 2D
• … in 3D
• … from 3D to 2D (camera!)
• … compute color values on 3D objects → lighting simulation
• … compute occlusion
• … model large scenes of many objects
• … to do all this using a GPU

• … use ray tracing to get shadows and reflections

Computer Graphics 2019/20 - Images and Colors 21


Next lectures …
• Simple Rasterization, Graphics APIs

Computer Graphics 2019/20 - Images and Colors 22

You might also like