82
Color To understand color, we must understand light

1 Color n To understand color, we must understand light

Embed Size (px)

Citation preview

Page 1: 1 Color n To understand color, we must understand light

1

Color

To understand color, we must understand light

Page 2: 1 Color n To understand color, we must understand light

2

Light

An electromagnetic phenomenon, like television waves, infrared radiation, and x-rays

Color involves those waves that lie in a narrow band of wavelengths in the “visible spectrum”

380nm 450nm 490nm 560nm 590nm 630nm 780nm

Page 3: 1 Color n To understand color, we must understand light

3

Light Photons

• all light is comprised of photons• properties: velocity, wavelength, frequency, polarization

wavelength = velocity / frequency

• interact with matter : transmitted, reflected, absorbed

Spectral Distribution• # of photons at each frequency/wavelength• visible spectrum

Page 4: 1 Color n To understand color, we must understand light

4

How would you convert?

How do you convert from rgb to wavelength?

How do you convert from wavelength to RGB?

380nm 450nm 490nm 560nm 590nm 630nm 780nm

Page 5: 1 Color n To understand color, we must understand light

5

What Is color? -perception

A source of light, an object, andthe eye - brain interaction…

Page 6: 1 Color n To understand color, we must understand light

6

How do we see color?

Experiments were done to observe and measure what people see.

OBSERVER

RG

B T

RI-

STIM

ULU

STES

T L

AM

P

Page 7: 1 Color n To understand color, we must understand light

7

Radiometry - How does light propagate in the real world?

700nm 400nm

pure light

spectral distribution

white light

Page 8: 1 Color n To understand color, we must understand light

8

Life and Death of a Photon

Emission

Reflection

Absorption

Page 9: 1 Color n To understand color, we must understand light

9

Pure Spectral light

The eye responds to light with wavelengths between approximately 400 and 700 nm

Some spectral densities for pure spectral light, and how we perceive them:

400 500 600 700

wavelength

SpectralDensity(powerper unitwavelength)

Vio

let

Blu

e Gre

en

Yel

low O

ran

ge

Red

Page 10: 1 Color n To understand color, we must understand light

10

Lighting is a Global Problem

That is, if you consider any point in the environment, it receives light from all around

Page 11: 1 Color n To understand color, we must understand light

11

Surfaces are Rarely Mirrors

Specular surface

Diffuse Surface

Page 12: 1 Color n To understand color, we must understand light

12

Some Simplifying Assumptions

Wavelength independence• No fluorescence

Time invariance• No phosphorescence

Light transport in a vacuum• No participating media

Objects are isotropic• Reflectance characteristics are constant

over the surface

Page 13: 1 Color n To understand color, we must understand light

13

color Response

Cones A = “Red” B = “Green” C = “Blue”

Page 14: 1 Color n To understand color, we must understand light

14

RGB Color Model

WHITE

MAGENTA (1,0,1)RED (1,0,0)

BLACK

GREEN (0,1,0) CYAN (0,1,1)

BLUE (0,0,1)

YELLOW (1,1,0)

Page 15: 1 Color n To understand color, we must understand light

15

The RGB Model

An Additive color model based on the primitives Red Green and Blue

Most Commonly used in Computer Graphics

Approximates human visual response fairly well

Page 16: 1 Color n To understand color, we must understand light

16

RGB Color Space

This is a vector space with the RGB basis vectors defined by the properties of the monitor phosphors.

Page 17: 1 Color n To understand color, we must understand light

17

Device Dependency Unfortunately the choice of red,

green and blue and be quite different in different implementations.

If the phosphors colors are slightly different the vector space is different so we cannot use RGB to universally define a unique color.

We require a device independent color space.

RGB Space 1

RGB Space 2

Page 18: 1 Color n To understand color, we must understand light

18

Color & Vision

CIE 1931 Model

The CIE 1931 model is the most commonly used It defines three primary “colors” X, Y and Z that can

be used to describe all visible colors, as well as a standard white, called C.

The range of colors that can be described by combinations of other colors is called a color gamut.

Since it is impossible to find three colors with a gamut containing all visible colors, the CIE’s three primary colors are imaginary. They cannot be seen, but they can be used to define other visible colors.

Page 19: 1 Color n To understand color, we must understand light

19

Color & Vision 2

CIE 1931 Model

To define a color in CIE model, provide weights for the X, Y and Z primaries, just as you would for an RGB display (e.g. C = xX + yY + zZ)

X, Y and Z form a three dimensional color volume We can ignore the dimension of luminance by

normalizing with total light intensity, X+Y+Z = 1. This gives chromaticity values:

x = X/X+Y+Zy = Y/X+Y+Zz = 1 - x - y

Page 20: 1 Color n To understand color, we must understand light

20

Color & Vision

CIE 1931 Model

Plotting x and y gives the CIE chromaticity diagram

• Color gamuts are found by taking the convex hull of the primary colors

• Complements are found by inscribing a line from the color through C to the edge of the diagram

y

x0

00.7

0.8

C

green

redblue

yellowcyan

purple700

600

520

400

500

Page 21: 1 Color n To understand color, we must understand light

21

Page 22: 1 Color n To understand color, we must understand light

22

Color & Vision

CIE 1931 Model

Page 23: 1 Color n To understand color, we must understand light

23

Y primary describes the luminance component

Amount of primaries to match a color is (x, y, z), given by

For a CRT k is 680 lumens per watt.

CIE Standard Specification

y

x k C x d y k C y d z k C z d ( ) ( ) ( ) ( ) ( ) ( )

C( )

Page 24: 1 Color n To understand color, we must understand light

24

A cone shaped volume that contains all the visible colors could be built in the XYZ space

If (x, y, z) are the weights to match a color C, then C = xX + yY + zZ

(x + y + z) (x + y + z) as

CIE Chromaticity Diagram

xcx

x y zyc

y

x y zzc

z

x y z

( ),

( ),

( )

X

Y

Z

Page 25: 1 Color n To understand color, we must understand light

25

CIE Chromaticity Diagram

If we specify xc and yc, then zc can be calculated as (1 - xc - yc). In addition if y (luminance) is specified than x and z could be calculated. So given (xc, yc, y) the transformation corresponding to (x, y, z) is given as

xxcyc

y y y zxc ycyc

y

, ,1

Page 26: 1 Color n To understand color, we must understand light

26

C

Page 27: 1 Color n To understand color, we must understand light

27

Uses of CIE Chromaticity Diagram

When three primary colors are used, then all the colors in the triangle formed by the three primaries could be produced

This helps in comparing color gamuts,

i.e. collection of colors

yc

xc

Page 28: 1 Color n To understand color, we must understand light

28

Color Models

Color model is a geometric representation of the space of all colors such that any color is a point in that space

Traditionally color models for computer graphics were designed for specific devices

They could be classified based on• Hardware color generation i.e. RGB for displays,

CMY for printers, YIQ for television transmission• Color perception i.e. HSV for interactive color

specification.

Page 29: 1 Color n To understand color, we must understand light

29

RGB Color Model

Standard Model for color monitor

Primaries are Red, Green and Blue

Represents only a subset of perceivable colors

Known as Additive Model, because individual contributions of each primary are added

color Applet (http://mc2.cchem.berkeley.edu/Java/RGB/example1.html)

Page 30: 1 Color n To understand color, we must understand light

30

CMY Color Model

Standard for ink-jet and xerographic printers

Primaries are Cyan, Magenta and Yellow

Known as Subtractive Model,

Printer color gamut is smaller than CRT color gamut

C = 1-R, M = 1-G and Y = 1-B

Page 31: 1 Color n To understand color, we must understand light

31

YIQ Color Model Used in commercial TV broadcasting Primaries are Y (luminance) and I, Q which are the chrominance components Y is same as the y primary of CIE standard Designed for transmission efficiency and compatibility

with black and white television Exploits two properties of human visual system

• high sensitivity to change in luminance than to color variations• Objects small in the field of view produce limited color

sensation

B

G

R

Q

I

Y

311.0528.0212.0

321.0275.0596.0

114.0587.0299.0

Page 32: 1 Color n To understand color, we must understand light

32

HSV Color Model

Useful in user interface design for color specification

Primaries are Hue, Saturation and Value (luminance)

Considered as direct geometric representation of perception of color

Based on cylindrical coordinate system

H

S

V

Cyan

1200

Green Yellow

Red 00

MagentaBlue2400

Black0.0

1.0

Page 33: 1 Color n To understand color, we must understand light

33

RGB Color Space

MagentaCyan

Yellow

GreenRed

Blue

BlackWhite

Page 34: 1 Color n To understand color, we must understand light

34

CIE Standard

Standard developed by Commission Internationale de L'Eclairage (1931): a way of defining any color based on the r + g + b = 1 plane.

Based on three primaries which are able to produce ALL visible colours.

CIE chromaticity diagram is the view you would get looking at the plane x + y + z = 1, straight down the blue axis

Provides a standard reference for comparing other color systems

Page 35: 1 Color n To understand color, we must understand light

35

CIE Chromticity Diagram

Less natural than RGB

However standard is useful for converting between color spaces of different devices

Page 36: 1 Color n To understand color, we must understand light

36

CMY color

Subtractive scheme based on primitives: Cyan, Magenta and Yellow

Commonly used in color print production

Page 37: 1 Color n To understand color, we must understand light

37

Subtractive Colors

Subtractive color mixing results from selective absorption of light wavelengths

Layers of CMY ink Layers of CMY ink subtract inverse subtract inverse percentages from percentages from the reflected light the reflected light so that we see a so that we see a particular color.particular color.

Page 38: 1 Color n To understand color, we must understand light

38

CMYK

'black' generated by mixing the subtractive primaries is not as dense as that of a genuine black ink (one that absorbs throughout the visible spectrum),

four-color printing uses black ink in addition to the subtractive primaries

C=cyan, M=magenta, Y=yellow, K=key (black)

Page 39: 1 Color n To understand color, we must understand light

39

Color Space Conversions

Y

M

C

B

G

R

1

1

1

B

G

R

Y

M

C

1

1

1

kkY

kkM

kkC

Y

M

C

)1(

)1(

)1(

RGB to CMY and CMY to RGB:RGB to CMY and CMY to RGB:

CMYK to CMY:CMYK to CMY:

Page 40: 1 Color n To understand color, we must understand light

40

color Matching

How much R,G,B do you need to make a particular “pure” color?

Page 41: 1 Color n To understand color, we must understand light

41

The EyeThe Biological Camera

Lens, cornea and fluids focus light.

Six eye muscles orient the eye

Iris adjusts light Retina captures

images

Page 42: 1 Color n To understand color, we must understand light

42

Physiology of Eye Response

6 million cones in the fovea• cones sense red green or blue light• color perception region is very small

120 million rods over the whole eye• peripheral vision• motion sensitive

Page 43: 1 Color n To understand color, we must understand light

43

Photometry - How do we see light?

Page 44: 1 Color n To understand color, we must understand light

44

Evolution’s camera

Page 45: 1 Color n To understand color, we must understand light

45

Spatial distribution (cross-section)

Page 46: 1 Color n To understand color, we must understand light

46

Rods versus cones Rods are more tolerant in terms of handling

low light conditions• You don’t see color when it’s night

Cones give you better spatial acuity

Page 47: 1 Color n To understand color, we must understand light

47

Cones come in three flavorsBlue Green

Red

Page 48: 1 Color n To understand color, we must understand light

48

Visual Cortex: Tristimulus Reality?

Types of Cones:• Low: 560 nm red ?• Medium: 530 nm green ?• High: 420 nm blue ?

Signal to brain:• L - M red - green• H - (L+M) blue - yellow• L + M red + green overall

luminance Red/Green color blindness means no signal

L – M signal.

Page 49: 1 Color n To understand color, we must understand light

49

How many colors can we see?

Humans can discriminate about• 200 hues• 20 saturation values• 500 brightness steps

The NBS (National Broadcasting Society) lists 267 color names

What about across languages?• Seem to be about 11 basic ones

– white, black, red, green, yellow, blue, brown, purple, pink, orange, gray

Page 50: 1 Color n To understand color, we must understand light

50

Cones

Types• “red”, “green”, “blue”

Page 51: 1 Color n To understand color, we must understand light

51

Hue

Hue, Saturation, Lightness/Value

Color Cone

Page 52: 1 Color n To understand color, we must understand light

52

RGB Color Cube

Page 53: 1 Color n To understand color, we must understand light

53

The negative values for thered matching function around 500nm indicate that these colors cannot be produced by adding the primaries.

Inferences - Color Matching Experiment

400 500 600 700-0.2

0

0.2

0.4 r ( )

g( )

b ( )

negative valuestr

isim

ulus

val

ue

Page 54: 1 Color n To understand color, we must understand light

54

Tristimulus vales are given by The color matching in the experiment is

perceptual matching. The spectrum resulting from adding the three

primaries need not match with the spectrum of the test light.

Lights which are perceptually same but have different spectral distribution curves are called metamers

Inferences - Color Matching Experiment

r C r d g C g d b C b d ( ) ( ) ( ) ( ) ( ) ( )

Page 55: 1 Color n To understand color, we must understand light

55

Color Quantization

Page 56: 1 Color n To understand color, we must understand light

56

Image Quantization

Image quantization: discretize continuous pixel values into discrete numbers

Color resolution/ color depth/ levels: - No. of colors or gray levels or- No. of bits representing each pixel value- No. of colors or gray levels Nc is given by

bcN 2

where b = no. of bits

Page 57: 1 Color n To understand color, we must understand light

57

Image Quantization : Quantization function

Light intensity

Qua

ntiz

atio

n le

vel

0

1

2

Nc-1

Nc-2

Darkest Brightest

Page 58: 1 Color n To understand color, we must understand light

58

Effect of Quantization Levels

256 levels 128 levels

32 levels64 levels

Page 59: 1 Color n To understand color, we must understand light

59

Effect of Quantization Levels (cont.)

16 levels 8 levels

2 levels4 levels

In this image,it is easy to seefalse contour.

Page 60: 1 Color n To understand color, we must understand light

60

Introduction• Some display hardware stores 8 bits per pixel

• To display a full-color image, the computer must choose an appropriate set of representative colors and map the image into these colors

This process is called

=> it can display at most 256 distinct colors at a time

Page 61: 1 Color n To understand color, we must understand light

61

Quantization phases• Sample the original image for color

statistics

• Select color map based on those statistics

• Map the colors to their representative

in the color map• Redraw the image, quantizing each pixel Algorithm

Mapping…

Page 62: 1 Color n To understand color, we must understand light

62

The Median Cut Algorithm

• The concept – to use each of the colors in the colormap to represent an equal number of pixels in the original image

• The algorithm repeatedly subdivides color space into smaller and smaller rectangular boxes

Page 63: 1 Color n To understand color, we must understand light

63

The Median Cut Algorithm (cont)

• Begin with one box which tightly encloses the colors of all image pixels

R

G

B

• Repeat for every newly created box:

(a) sort enclosed points along the longest dimension of the box

(b) segregate points into two halves at the median point

• Until the desired number of boxes is generated

• Compute representative for each box by averaging the colors contained in each

Page 64: 1 Color n To understand color, we must understand light

64

The Median Cut Algorithm - samples

2 colors

256 colors

16 colors

4 colors

Page 65: 1 Color n To understand color, we must understand light

65

The Popularity Algorithm

• Run a histgoram on the entire picture to determine “pixel counts” for each color

• Pick the colors with the highest pixel count

colors

frequency

Page 66: 1 Color n To understand color, we must understand light

66

The Popularity Algorithm - samples

2 colors

256 colors

16 colors

4 colors

Page 67: 1 Color n To understand color, we must understand light

67

The Original Diversity Algorithm

• Run a histogram on the entire picture

• Pick the color with the highest pixel count

• Repeat

• Until all colors have been picked

(a) find the color in the unpicked list that is furthest from all of the colors in the picked list(b) pick this color

Page 68: 1 Color n To understand color, we must understand light

68

The Original Diversity Algorithm –samples

2 colors

256 colors

16 colors

4 colors

Page 69: 1 Color n To understand color, we must understand light

69

The Modified Diversity Algorithm

• Run a histogram on the entire picture

• The 1st color: the most popular

• The 2nd color: the furthest away from the first color• The 3rd through 10th colors: are picked using the normal Diversity Algorithm

• Repeat

(a) pick a color on popularity(b) pick a color on diversity

• Until all the colors have been picked

Page 70: 1 Color n To understand color, we must understand light

70

The Modified Diversity Algorithm - samples

2 colors

256 colors

16 colors

4 colors

Page 71: 1 Color n To understand color, we must understand light

71

Sequential Scalar Quantization

R

G• Quantize R component to some predetermined number of levels N1 according to its marginal distribution

B21 B22 B2N1

• Quantize G within each B2j to n2j

levels according to its conditional distribution (this results in a set of N2 columnar regions B3j)

B31

B32 B3N2

• Quantize B within each B3j (this results in the desired N3 = N quantization regions)

• Pick the centroid of each of the N regions as the representative for that region

x

x

x

x

x

x

xx

x

x

Page 72: 1 Color n To understand color, we must understand light

72

Sequential Scalar Quantization - samples

2colors

256colors

16colors

4colors

Page 73: 1 Color n To understand color, we must understand light

73

Generalized Lloyd Algorithm

• Consists on a number of iterations, each one recomputing the set of more appropriate partitions of the input vectors and their centroids

Page 74: 1 Color n To understand color, we must understand light

74

Generalized Lloyd Algorithm (cont)

• Begin with an initial data• Repeat

(a) redistribute each input vector into one of the clusters defined by their centroids

(b) recompute the centroids for each cluster just created

(c) compute the average distortion for the new centroid set

• Until the distortion has only changed by a small enough amount since the last iteration

c01 c21c11 c31

c00 c20c10 c30

image colors

representatives

Page 75: 1 Color n To understand color, we must understand light

75

Generalized Lloyd Algorithm - samples

original

Diversity4 colors

Diversity+ GLA

original

Popularity16 colors

Popularity+ GLA

Page 76: 1 Color n To understand color, we must understand light

76

Peak signal to noise ratio (PSNR)

M,N – picture dimensions

noise(i,j,k) – distance between an original

color of a pixel (located at (i,j,k)) and its color after

quantization

10*log10( Max(original image)2*3*M*N

)ΣiΣjΣk noise(i,j,k)2

PSNR(3D case) =

Page 77: 1 Color n To understand color, we must understand light

77

SummaryPSNR

MC P D DM SSQ

13.752

9.9089.9088.768

13.56913.752 13.745 13.75213.752

14.537

Algorithm

2 color quantization

- GLA applying- no GLA applying

MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization

Page 78: 1 Color n To understand color, we must understand light

78

Summary (cont)Summary (cont)

PSNR

MC P D DM SSQ

17.197

11.23110.875

12.137

17.08518.225 18.216

18.26318.26319.053

Algorithm

4 color quantization

- GLA applying- no GLA applying

MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization

Page 79: 1 Color n To understand color, we must understand light

79

Summary (cont)Summary (cont)

PSNR

MC P D DM SSQ

22.259

17.968

13.437

16.606

22.157

23.82623.056

25.856

23.21424.648

Algorithm

16 color quantization

- GLA applying- no GLA applying

MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization

Page 80: 1 Color n To understand color, we must understand light

80

Summary (cont)Summary (cont)

PSNR

MC P D DM SSQ

27.12225.856

18.747

28.73531.18732.697

33.39731.606

30.333

34.042

Algorithm

256 color quantization

- GLA applying- no GLA applying

MC - Median CutP - PopularityD - DiversityDM - Diversity (Modified)SSQ – Sequential Scalar Quantization

Page 81: 1 Color n To understand color, we must understand light

81

CR311 HW

Mult-color edge detector:• Input a color image, img,and color

quanitzation algorithm, imgk = Q(img,k)• Create img4, img8 and img16 with 4 8 and 16

colors• Edge detect img[] with an isotropic edge

detector• Create imgSum = img4+img8+img16• Normalize imgsum and threshold, with an

adjustment.

Page 82: 1 Color n To understand color, we must understand light

82

New HW for CR311

Implement color quantization algorithms in the ip package using the MDI interface.• Linear cut• Median cut• Wu• Octree and NuQuant• printNumber of Colors