CSE
409:
Computer
Graphics
Color
Department of CSE, BUET Department of CSE, BUET Acknowledgements: parts of information and pictures has been collected from MIT, Berkeley and UVa
Md. Tanvir Al Amin
Color
To
understand
how
to
make
realistic
images,
we
need
a
basic
understanding
of
the
physics
and
physiology
of
vision.
To
understand
how
to
make
realistic
images,
we
need
a
basic
understanding
of
the
physics
and
physiology
of
vision.
Elements
of
color
Elements
of
color
Elements
of
color
Elements
of
color
The
color
of
an
object
depends
on
• object
itself
The
color
of
an
object
depends
on
• object
itself
Department of CSE, BUET Department of CSE, BUET
• light
source
• color
of
the
surrounding
area
• Human
visual
system
• light
source
• color
of
the
surrounding
area
• Human
visual
system
Color
•
Some
objects
reflect
light,
whereas
others
also
transmit
light
•
Some
objects
reflect
light,
whereas
others
also
transmit
light
•
When
a
surface
that
reflects
only
pure
blue
light
is
illuminated
with
pure
red
light,
it
appears
black.
•
Similarly
a
pure
green
light
viewed
through
glass
that
transmits
only
pure
red
will
also
appear
black.
•
When
a
surface
that
reflects
only
pure
blue
light
is
illuminated
with
pure
red
light,
it
appears
black.
•
Similarly
a
pure
green
light
viewed
through
glass
that
transmits
only
y p
y p
pure
red
will
also
appear
pp
pp
black.
Basics
of
Color
Physics:
•
Illumination
Physics:
•
Illumination
Illumination
–
Electromagnetic
spectra
•
Reflection
–
Material
properties
–
Surface
geometry
and
microgeometry
(i.e.,
polished
versus
matte
versus
brushed)
Perception
Illumination
–
Electromagnetic
spectra
•
Reflection
–
Material
properties
–
Surface
geometry
and
microgeometry
(i.e.,
polished
versus
matte
versus
brushed)
Perception
Physiology
of
Vision
The
eye:
The
eye:
The
retina
•
Rods
•
Cones
C l !
The
retina
•
Rods
•
Cones
C l !
Department of CSE, BUET Department of CSE, BUET
–
Color!
–
Color!
Physiology
of
Vision
The center of the retina is a densely packed region
The center of the retina is a densely packed region
ll d th
ll d th
ff
The center of the retina is a densely packed region
The center of the retina is a densely packed region
ll d th
ll d th
ff
called the
called the
fovea
fovea
.
.
Cones much denser here than the
Cones much denser here than the periphery
periphery
called the
called the
fovea
fovea
.
.
Cones much denser here than the
Cones much denser here than the periphery
periphery
Department of CSE, BUET Department of CSE, BUET
Physiology
of
Vision:
Cones
Three
types
of
cones:
•
L
or
R
,
most
sensitive
to
red
light
(610
nm)
•
M
or
G
most sensitive to green light (560 nm)
Three
types
of
cones:
•
L
or
R
,
most
sensitive
to
red
light
(610
nm)
•
M
or
G
most sensitive to green light (560 nm)
•
M
or
G
,
most
sensitive
to
green
light
(560
nm)
•
S
or
B
,
most
sensitive
to
blue
light
(430
nm)
•
M
or
G
,
most
sensitive
to
green
light
(560
nm)
•
S
or
B
,
most
sensitive
to
blue
light
(430
nm)
Department of CSE, BUET Department of CSE, BUET
•
Color
blindness
results
from
missing
cone
type(s)
•
Color
blindness
results
from
missing
cone
type(s)
Physiology
of
Vision:
The
Retina
Strangely,
rods
and
cones
are
at
the
back
of the retina behind a mostly
‐
Strangely,
rods
and
cones
are
at
the
back
of the retina behind a mostly
‐
back
of
the
retina,
behind
a
mostly
transparent
neural
structure
that
collects
their
response.
http://www.trueorigin.org/retina.asp
back
of
the
retina,
behind
a
mostly
transparent
neural
structure
that
collects
their
response.
http://www.trueorigin.org/retina.asp
Perception:
Metamers
A
given
perceptual
sensation
of
color
derives
from
the
stimulus
of
all
three
cone
types
A
given
perceptual
sensation
of
color
derives
from
the
stimulus
of
all
three
cone
types
Department of CSE, BUET Department of CSE, BUET
Identical perceptions of color can thus be caused
Identical perceptions of color can thus be caused
by very different spectra
by very different spectra
Identical perceptions of color can thus be caused
Identical perceptions of color can thus be caused
by very different spectra
by very different spectra
What
is
Color?
Spectral Power Electromagnetic Wave
Reflectance Spectrum
Spectral
Distribution
Illuminant D65
(nm)
Department of CSE, BUET Department of CSE, BUET
Power Distribution
What
is
Color?
Spectral Power Distribution
Neon Lamp
Reflectance Spectrum
Distribution
Illuminant F1
Spectral Power Distribution Under D65
Spectral Power Distribution
What
is
Color?
Observer
Stimulus
What
is
Color?
Spectral Sensibility of the L, M and S
S
M
L
Ganglion Cells
Horizontal Cells Bipolar
Cells RodCone
Department of CSE, BUET Department of CSE, BUET
Cones
Rods
Rods
Cones
Cones
Cones and Rods
Cones and Rods
Distribution of
Distribution of
Light
Light
Retina Optic Nerve Amacrine
Cells
What
is
Color?
Right LGN
Right LGN
Visual
Visual
Left LGN
Left LGN
Department of CSE, BUET Department of CSE, BUET
Visual
Visual
Cortex
Cortex
LGN = Lateral Geniculate Nucleus
Perception:
Other
Gotchas
Color
perception
is
also
difficult
because:
•
It
varies
from
person
to
person
Color
perception
is
also
difficult
because:
•
It
varies
from
person
p
to
person
p
•
It
is
affected
by
adaptation
(stare
at
a
light
bulb…
don’t)
•
It
is
affected
by
surrounding
color:
p
p
•
It
is
affected
by
adaptation
(stare
at
a
light
bulb…
don’t)
•
It
is
affected
by
surrounding
color:
Department of CSE, BUET Department of CSE, BUET
Perception:
Relative
Intensity
We
are
not
good
at
judging
absolute
intensity
Let’s
illuminate
pixels
with
white
light
on
scale
of
0
‐
1.0
We
are
not
good
at
judging
absolute
intensity
Let’s
illuminate
pixels
with
white
light
on
scale
of
0
‐
1.0
Intensity
difference
of
neighboring
colored
rectangles
with
intensities:
0.10
→
0.11
(10%
change)
0.50
→
0.55
(10%
change)
will look the same
Intensity
difference
of
neighboring
colored
rectangles
with
intensities:
0.10
→
0.11
(10%
change)
0.50
→
0.55
(10%
change)
will look the same
Department of CSE, BUET Department of CSE, BUET
will
look
the
same
We
perceive
relative
intensities,
not
absolute
will
look
the
same
Representing
Intensities
Remaining
in
the
world
of
black
and
white…
Use photometer to obtain min and max brightness of monitor
Remaining
in
the
world
of
black
and
white…
Use photometer to obtain min and max brightness of monitor
II
II
Use
photometer
to
obtain
min
and
max
brightness
of
monitor
This
is
the
dynamic
range
Intensity
ranges
from
min,
I
0,
to
max,
1.0
How
do
we
represent
256
shades
of
gray?
Use
photometer
to
obtain
min
and
max
brightness
of
monitor
This
is
the
dynamic
range
Intensity
ranges
from
min,
I
0,
to
max,
1.0
How
do
we
represent
256
shades
of
gray?
Equal distribution between min and max fails
Equal distribution between min and max fails
Equal distribution between min and max fails
Equal distribution between min and max fails
II
0
0
=I
=I
0
0
II
1
1
= rI
= rI
0
0
II
2
2
= rI
= rI
1
1
= r
= r
2
2
II
0
0
Department of CSE, BUET Department of CSE, BUET
relative change near max is much smaller than near I
relative change near max is much smaller than near I
00Preserve % change
Preserve % change
II
nn= r
= r
nnII
00, n > 0 r = (1/I
, n > 0 r = (1/I
00))
1/n1/nSo, I
So, I
jj= I
= I
00(n(n--j)/nj)/n0
0
≤
≤
j
j
≤≤
n
n
For n = 3, r =2, we got four intensities
⅛
, ¼, ½, 1
For n = 3, r =2, we got four intensities
⅛
, ¼, ½, 1
relative change near max is much smaller than near I
relative change near max is much smaller than near I
00Preserve % change
Preserve % change
II
nn= r
= r
nnII
00, n > 0 r = (1/I
, n > 0 r = (1/I
00))
1/n1/nSo, I
So, I
jj= I
= I
00(n(n--j)/nj)/n0
0
≤
≤
j
j
≤≤
n
n
For n = 3, r =2, we got four intensities
⅛
, ¼, ½, 1
For n = 3, r =2, we got four intensities
⅛
, ¼, ½, 1
…
…
II
255
255
=rI
=rI
254
254
=r
=r
255
255
II
0
0
Dynamic
Ranges
Dynamic
Range
Max
#
of
Display
(max
/
min
illum)
Perceived
Dynamic
Range
Max
#
of
Display
(max
/
min
illum)
Perceived
Intensities
(r
=
1.01)
CRT:
50
‐
200
400
‐
530
Photo
(print)
100
465
Photo
(slide)
1000
700
B/W printout
100
465
Intensities
(r
=
1.01)
CRT:
50
‐
200
400
‐
530
Photo
(print)
100
465
Photo
(slide)
1000
700
B/W printout
100
465
Department of CSE, BUET Department of CSE, BUET
B/W
printout
100
465
Color
printout
50
400
Newspaper
10
234
B/W
printout
100
465
Color
printout
50
400
Newspaper
10
234
Gamma
Correction
But
most
display
devices
are
inherently
nonlinear:
Intensity =
k(voltage)
is between 2 2 and 2 5 on most monitors
But
most
display
devices
are
inherently
nonlinear:
Intensity =
k(voltage)
is between 2 2 and 2 5 on most monitors
Intensity
=
k(voltage)
,
is
between
2.2
and
2.5
on
most
monitors
For
intensity
I,
we
need
to
find
j
=
ROUND(log
r(I/I
0))
from
lookup
table
After
j
is
found,
we
calculate
I
j=
r
jI
0and
V
j=
ROUND((I
j/K)
1/Common
solution:
gamma
correction
•
Post
‐
transformation
on
intensities
to
map
them
to
linear
range
on
display
device:
Intensity
=
k(voltage)
,
is
between
2.2
and
2.5
on
most
monitors
For
intensity
I,
we
need
to
find
j
=
ROUND(log
r(I/I
0))
from
lookup
table
After
j
is
found,
we
calculate
I
j=
r
jI
0and
V
j=
ROUND((I
j/K)
1/Common
solution:
gamma
correction
•
Post
‐
transformation
on
intensities
to
map
them
to
linear
range
on
display
device:
•
Can
have
separate
for
R,
G,
B
How
many
intensities
are
enough?
r
=
(1/I
0)
1/nSo,
n
=
log
1.01(1/I
0)
•
Can
have
separate
for
R,
G,
B
How
many
intensities
are
enough?
r
=
(1/I
0)
1/nSo,
n
=
log
1.01(1/I
0)
1
x
y
Gamma
Correction
Some
monitors
perform
the
gamma
correction
in
hardware
(SGIs)
Some
monitors
perform
the
gamma
correction
in
hardware
(SGIs)
Others
do
not
(most
PCs)
Tough
to
generate
images
that
look
good
on
both
platforms
(i.e.
images
from
web
pages)
Others
do
not
(most
PCs)
Tough
to
generate
images
that
look
good
on
both
Specifying
Color
Color
perception
usually
involves
three
quantities:
•
Hue
: Distinguishes between colors like red, green, blue, etc
Color
perception
usually
involves
three
quantities:
•
Hue
: Distinguishes between colors like red, green, blue, etc
•
Saturation
: How far the color is from a gray of equal intensity
•
Lightness
: The perceived intensity of a reflecting object
Sometimes
lightness
is
called
brightness
if
the
object
is
emitting
light
instead
of
reflecting
it.
•
Saturation
: How far the color is from a gray of equal intensity
•
Lightness
: The perceived intensity of a reflecting object
Sometimes
lightness
is
called
brightness
if
the
object
is
emitting
light
instead
of
reflecting
it.
Department of CSE, BUET Department of CSE, BUET
In
order
to
use
color
precisely
in
computer
graphics,
we
need
to
be
able
to
specify
and
measure
colors.
In
order
to
use
color
precisely
in
computer
graphics,
we
need
to
be
able
to
specify
and
measure
colors.
Combining
Colors
Additive (RGB)
Subtractive (CMYK)
Additive (RGB)
Shining colored lights
on a white ball
Subtractive (CMYK)
Mixing paint colors and
illuminating with white light
Department of CSE, BUET Department of CSE, BUET
How
Do
Artists
Do
It?
Artists
often
specify
color
as
tints,
shades,
and
tones
of
saturated
(pure)
pigments
Artists
often
specify
color
as
tints,
shades,
and
tones
of
saturated
(pure)
pigments
pigments
Tint
:
Gotten
by
adding
white
to
a
pure
pigment,
decreasing
saturation
Shade
:
Gotten
by
adding
black
to
a
pure
pigment,
decreasing
lightness
pigments
Tint
:
Gotten
by
adding
white
to
a
pure
pigment,
decreasing
saturation
Shade
:
Gotten
by
adding
black
to
a
pure
pigment,
decreasing
lightness
White
Department of CSE, BUET Department of CSE, BUET
Tone
:
Gotten
by
adding
white
and
black
to
a
pure
pigment
Tone
:
Gotten
by
adding
white
and
black
to
a
pure
pigment
Pure Color
Black
Grays
Tones
HSV
Color
Space
Computer
scientists
frequently
use
an
intuitive
color
space
that
corresponds
to
tint,
shade,
and
tone:
Computer
scientists
frequently
use
an
intuitive
color
space
that
corresponds
to
tint,
shade,
and
tone:
•
Hue
‐
The
color
we
see
(red,
green,
purple)
•
Saturation
‐
How
far
is
the
color
from
gray
(pink
is
less
saturated
than
red,
sky
blue
is
less
saturated
than
royal
blue)
•
Brightness
(Luminance)
‐
How
bright
is
the
color
(how
bright
are
•
Hue
‐
The
color
we
see
(red,
green,
purple)
•
Saturation
‐
How
far
is
the
color
from
gray
(pink
is
less
saturated
than
red,
sky
blue
is
less
saturated
than
royal
blue)
•
Brightness
(Luminance)
‐
How
bright
is
the
color
(how
bright
are
Department of CSE, BUET Department of CSE, BUET
HSV
Color
Model
Hue (H) is the angle
Hue (H) is the angle
around the vertical axis
around the vertical axis
around the vertical axis
around the vertical axis
Saturation (S) is a value
Saturation (S) is a value
from 0 to 1 indicating
from 0 to 1 indicating
how far from the vertical
how far from the vertical
axis the color lies
axis the color lies
Department of CSE, BUET Department of CSE, BUET
Value (V) is the height of
Value (V) is the height of
the hexcone”
the hexcone”
HSV
Color
Model
H S V Color
0
1.0
1.0
Red
120
1.0
1.0
Green
240
1.0
1.0
Blue
*
0.0
1.0
White
*
0.0
0.5
Gray
*
*
0.0
Black
Department of CSE, BUET Department of CSE, BUET
60
1.0
1.0
?
270
0.5
1.0
?
270
0.0
0.7
?
Intuitive
Color
Spaces
A top
A top--down view of hexcone
down view of hexcone
A top
A top--down view of hexcone
down view of hexcone
HSV
Color
Space
A
more
intuitive
color
space
A
more
intuitive
color
space
Value
Saturation
•
H
=
Hue
•
S
=
Saturation
•
V
=
Value
(or
brightness)
•
H
=
Hue
•
S
=
Saturation
•
V
=
Value
(or
brightness)
Value
Precise
Color
Specifications
•
Pigment
‐
mixing
is
subjective
‐‐‐
depends
on
human
observer,
surrounding
colors,
lighting
of
the
environment,
etc
•
Pigment
‐
mixing
is
subjective
‐‐‐
depends
on
human
observer,
surrounding
colors,
lighting
of
the
environment,
etc
•
We
need
an
objective
color
specification
•
We
seek
help
from
a
branch
of
Physics
“Colorimetry”
•
Light
is
electromagnetic
energy
in
the
400
to
700
nm
wavelength
range
•
Dominant wavelength
is
the
wavelength
of
the
color
we
“see”
E it ti
it
i th
ti
f
l
d li ht t
hit li ht
•
We
need
an
objective
color
specification
•
We
seek
help
from
a
branch
of
Physics
“Colorimetry”
•
Light
is
electromagnetic
energy
in
the
400
to
700
nm
wavelength
range
•
Dominant wavelength
is
the
wavelength
of
the
color
we
“see”
E it ti
it
i th
ti
f
l
d li ht t
hit li ht
Department of CSE, BUET Department of CSE, BUET
•
Excitation purity
is
the
proportion
of
pure
colored
light
to
white
light
•
Luminance
is
the
amount
(or
intensity)
of
the
light
•
Excitation purity
is
the
proportion
of
pure
colored
light
to
white
light
•
Luminance
is
the
amount
(or
intensity)
of
the
light
Electromagnetic
Spectrum
Visible
light
frequencies
range
between
...
•
Red
=
4.3
x
1014
hertz
(700nm)
Visible
light
frequencies
range
between
...
•
Red
=
4.3
x
1014
hertz
(700nm)
(
)
•
Violet
=
7.5
x
1014
hertz
(400nm)
(
)
•
Violet
=
7.5
x
1014
hertz
(400nm)
Department of CSE, BUET Department of CSE, BUET
Visible
Light
Hue
=
dominant
frequency
(highest
peak)
Saturation
=
excitation
purity
(ratio
of
highest
to
rest)
Hue
=
dominant
frequency
(highest
peak)
Saturation
=
excitation
p
purity
y (
(ratio
of
f g
highest
to
rest)
)
Lightness
=
luminance
(area
under
curve)
p
y (
f g
)
Lightness
=
luminance
(area
under
curve)
Department of CSE, BUET Department of CSE, BUET
White Light
Orange Light
How
well
do
we
see
color?
What color do we see the best?
•
Yellow
‐
green
at
550
nm
What color do we see the worst?
What color do we see the best?
•
Yellow
‐
green
at
550
nm
What color do we see the worst?
What color do we see the worst?
•
Blue
at
440
nm
Flashback: Colortables (colormaps) for color storage
•
Which
RGB
value
gets
the
most
bits?
Can perceive color differences of 10 nm at extremes (violet and red) and 2 nm between blue
and yellow
diff
di i
l
k lik
h
l
What color do we see the worst?
•
Blue
at
440
nm
Flashback: Colortables (colormaps) for color storage
•
Which
RGB
value
gets
the
most
bits?
Can perceive color differences of 10 nm at extremes (violet and red) and 2 nm between blue
and yellow
diff
di i
l
k lik
h
l
Department of CSE, BUET Department of CSE, BUET
Metamers
– different energy radiations look like the same color
Color perception also affected by surrounding light and adaptation
Just
noticeable
difference
(JND)
128
fully
saturated
hues
can
be
distinguished
Cannot
perceive
hue
differences
with
less
saturated
light.
128
fully
saturated
hues
can
be
distinguished
Cannot
p
perceive
hue
differences
with
less
saturated
light.
g
Sensitivity
to
changes
in
saturation
for
a
fixed
hue
and
brightness
ranges
from
16
to
23
depending
on
hue.
p
g
Sensitivity
to
changes
in
saturation
for
a
fixed
hue
and
brightness
ranges
from
16
to
23
depending
on
hue.
Department of CSE, BUET Department of CSE, BUET
Human
Color
Vision
Humans
have
3
light
sensitive
pigments
in
their
cones,
called
L,
M,
and S
Humans
have
3
light
sensitive
pigments
in
their
cones,
called
L,
M,
and S
and
S
Each
has
a
different
spectral
response
curve
:
and
S
Each
has
a
different
spectral
response
curve
:
L
L
(
)
E
(
)
d
M
M
(
)
E
(
)
d
Department of CSE, BUET Department of CSE, BUET
This
leads
to
metamerism
“Tristimulus”
color
theory
This
leads
to
metamerism
“Tristimulus”
color
theory
M
M
(
)
E
(
)
d
S
S
(
)
E
(
)
d
Color
Spaces
Three
types
of
cones
suggests
color
is
a
3D
quantity.
How
to
define
3D
color
space?
Three
types
of
cones
suggests
color
is
a
3D
quantity.
How
to
define
3D
color
space?
Idea:
•
Shine given wavelength (
) on a screen
•
User must control three lasers producing three wavelengths (say R=700nm,
G=546nm, and B=436nm)
•
Adjust intensity of RGB until colors are identical
Idea:
•
Shine given wavelength (
) on a screen
•
User must control three lasers producing three wavelengths (say R=700nm,
G=546nm, and B=436nm)
•
Adjust intensity of RGB until colors are identical
•
Adjust intensity of RGB until colors are identical
•
Note phosphors of TV are not perfect RGB
emitters as the results to right demonstrate
•
Adjust intensity of RGB until colors are identical
•
Note phosphors of TV are not perfect RGB
emitters as the results to right demonstrate
CIE
color
matching:
same
for
color
Primaries
(synthesis)
at
435.8,
546.1
and
700
•
Chosen
for
robust
reproduction,
good
separation
in
red
‐
green
Primaries
(synthesis)
at
435.8,
546.1
and
700
•
Chosen
for
robust
reproduction,
good
separation
in
red
‐
green
CIE
color
matching
Primaries
(synthesis)
at
435.8,
546.1
and
700
•
For
robust
reproduction,
good
separation
in
red
‐
green
Primaries
(synthesis)
at
435.8,
546.1
and
700
•
For
robust
reproduction,
good
separation
in
red
‐
green
Measure
matching
curves
as
function
of
wavelength
(analysis)
N t th t th
i
i
Measure
matching
curves
as
function
of
wavelength
(analysis)
N t th t th
i
i
Department of CSE, BUET Department of CSE, BUET
Note
that
the
primaries
(monochromatic
435.8,
546.1
and
700nm)
are
not
the
same
as
the
matching
curve!!!)
Note
that
the
primaries
(monochromatic
435.8,
546.1
and
700nm)
are
not
the
same
as
the
matching
curve!!!)
Color Matching Problem
Some colors cannot be produced using only positively
weighted primaries
Some colors cannot be produced using only positively
weighted primaries
Solution: add light on the other side!
Solution: add light on the other side!
Department of CSE, BUET Department of CSE, BUET
Color
matching
experiment
1
Department of CSE, BUET Department of CSE, BUET