Slide 1

Slide 1 text

let’s talk about… COLORS

Slide 2

Slide 2 text

Color Spaces Gamma & Linear

Slide 3

Slide 3 text

Gamma & Linear

Slide 4

Slide 4 text

0, 0, 0 255, 255, 255

Slide 5

Slide 5 text

0, 0, 0 255, 255, 255 127, 127, 127 ?

Slide 6

Slide 6 text

0, 0, 0 255, 255, 255 127, 127, 127 ? 128, 128, 128 ?

Slide 7

Slide 7 text

0, 0, 0 255, 255, 255 127, 127, 127 ? 128, 128, 128 ? 186, 186, 186 ?

Slide 8

Slide 8 text

You are doing it wrong

Slide 9

Slide 9 text

You are doing it wrong —— — — — — — —— —

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

A CRT uses an electron gun fired at a phosphorescent screen

Slide 12

Slide 12 text

A CRT uses an electron gun fired at a phosphorescent screen

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Gamma 2.2

Slide 17

Slide 17 text

Gamma 2.2

Slide 18

Slide 18 text

Gamma 2.2 Gamma Correction

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

what about LCD? >>>>>>>>>>>>> <<<<<<<<<<<<<

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

The eye’s response is non-linear

Slide 23

Slide 23 text

Our visual system follows Steven’s power law The eye’s response is non-linear

Slide 24

Slide 24 text

Our visual system follows Steven’s power law The eye’s response is non-linear

Slide 25

Slide 25 text

Our visual system follows Steven’s power law The eye’s response is non-linear Magnitude of stimulus

Slide 26

Slide 26 text

Our visual system follows Steven’s power law The eye’s response is non-linear Subjective magnitude of sensation Magnitude of stimulus

Slide 27

Slide 27 text

Our visual system follows Steven’s power law The eye’s response is non-linear Gamma! Subjective magnitude of sensation Magnitude of stimulus

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

The response curve of an LCD is not a gamma curve

Slide 30

Slide 30 text

The response curve of an LCD is not a gamma curve It is made to look like a gamma curve with hardware processing

Slide 31

Slide 31 text

We gamma-encode to optimize bandwidth and storage It is a compression scheme

Slide 32

Slide 32 text

Linear Gamma Input quantized over 5 bits for visualization 50% of the precision allocated to the darkest 50% intensities 70% of the precision allocated to the darkest 50% intensities 11~12 bits needed 8 bits are sufficient

Slide 33

Slide 33 text

Gamma encoding is not necessary with high precision, linear formats Examples: OpenEXR, PNG 16 bit, Photoshop 16 & 32 bit, RAW files

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

findViewById(R.id.root).setBackground(0xfff32272); Gamma encoded

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

a=0

Slide 40

Slide 40 text

a=0 b=1

Slide 41

Slide 41 text

a=0 b=1 c=0.5

Slide 42

Slide 42 text

c=0.5

Slide 43

Slide 43 text

c=0.21 c=0.5

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

This issue affects everything

Slide 47

Slide 47 text

Blurs & resizes → darker image This issue affects everything

Slide 48

Slide 48 text

Blurs & resizes → darker image Animations → brightness shifts This issue affects everything

Slide 49

Slide 49 text

Blurs & resizes → darker image Animations → brightness shifts 3D lighting → hue shifts This issue affects everything

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

>>>>>>>>>>>>>>linear space<<<<<<<<<<<<<< Do all the math in

Slide 52

Slide 52 text

// Gamma encoded colors
 int color1 = getColor1();
 int color2 = getColor2();
 
 // Extract red and convert to linear
 float r1 = ((color2 >> 16) & 0xff) / 255.0f;
 r1 = (float) Math.pow(r1, 2.2); float r2 = // …
 
 // Do the math and gamma-encode
 float r = r1 * 0.5f + r2 * 0.5f;
 r = (float) Math.pow(r, 1.0 / 2.2);

Slide 53

Slide 53 text

// Do not gamma-decode alpha // Alpha is *linear*!

Slide 54

Slide 54 text

// OpenGL has extensions and APIs // for sRGB encoding/decoding and // correct, linear blending // Use them, it’s free

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Color Spaces It’s more complicated

Slide 57

Slide 57 text

What is a color?

Slide 58

Slide 58 text

What is a color? For users, it’s a visual perception that can be described by hue, brightness and colorfulness

Slide 59

Slide 59 text

What is a color? For users, it’s a visual perception that can be described by hue, brightness and colorfulness

Slide 60

Slide 60 text

What is a color? For users, it’s a visual perception that can be described by hue, brightness and colorfulness For developers, it’s a tuple of numbers, in a color model associated with a color space

Slide 61

Slide 61 text

What is a color? For users, it’s a visual perception that can be described by hue, brightness and colorfulness For developers, it’s a tuple of numbers, in a color model associated with a color space RGB(0.92,0.91,0.86) CMYK(0.5,0.3,0.6,0)

Slide 62

Slide 62 text

Visible Spectrum CIE 1931 Chromaticity Diagram

Slide 63

Slide 63 text

sRGB AdobeRGB ProPhotoRGB Common RGB color spaces

Slide 64

Slide 64 text

What is a color space?

Slide 65

Slide 65 text

It has 3 primaries What is a color space?

Slide 66

Slide 66 text

It has 3 primaries It has a white point What is a color space?

Slide 67

Slide 67 text

It has 3 primaries It has a white point It has conversion functions What is a color space?

Slide 68

Slide 68 text

sRGB AdobeRGB ProPhotoRGB Common RGB color spaces

Slide 69

Slide 69 text

Conversion functions

Slide 70

Slide 70 text

Equivalent of the gamma functions Conversion functions

Slide 71

Slide 71 text

Equivalent of the gamma functions Opto-electronic conversion function (OECF) Conversion functions

Slide 72

Slide 72 text

Equivalent of the gamma functions Opto-electronic conversion function (OECF) Electro-optical conversion function (EOCF) Conversion functions

Slide 73

Slide 73 text

Which color space?

Slide 74

Slide 74 text

Which color space? Unless you know otherwise, always assume sRGB

Slide 75

Slide 75 text

sRGB

Slide 76

Slide 76 text

sRGB

Slide 77

Slide 77 text

float OECF_sRGB(float linear) {
 float low = linear * 12.92f;
 float high = (pow(linear, 1.0f / 2.4f) * 1.055f) - 0.055f;
 return linear <= 0.0031308f ? low : high;
 }

Slide 78

Slide 78 text

Easy to optimize

Slide 79

Slide 79 text

Easy to optimize Use lookup tables, 8 bits for encoding, 16 bits for decoding

Slide 80

Slide 80 text

Easy to optimize Use lookup tables, 8 bits for encoding, 16 bits for decoding

Slide 81

Slide 81 text

Easy to optimize Use lookup tables, 8 bits for encoding, 16 bits for decoding

Slide 82

Slide 82 text

OECF

Slide 83

Slide 83 text

Android TV

Slide 84

Slide 84 text

HDTV, Rec.709 Android TV

Slide 85

Slide 85 text

HDTV, Rec.709 →Same primaries & white point as sRGB Android TV

Slide 86

Slide 86 text

HDTV, Rec.709 →Same primaries & white point as sRGB →Different OECF/EOCF, ≈gamma 2.4 Android TV

Slide 87

Slide 87 text

HDTV, Rec.709 →Same primaries & white point as sRGB →Different OECF/EOCF, ≈gamma 2.4 UHDTV, Rec.2020 Android TV

Slide 88

Slide 88 text

HDTV, Rec.709 →Same primaries & white point as sRGB →Different OECF/EOCF, ≈gamma 2.4 UHDTV, Rec.2020 →Similar OECF/EOCF to Rec.709 Android TV

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

You are doing it wrong

Slide 92

Slide 92 text

You are doing it wrong —— — — — — — —— —

Slide 93

Slide 93 text

Android is doing it wrong

Slide 94

Slide 94 text

Gradients Animations (fixed in N) Bitmap resize Blending Anti-aliasing Etc…

Slide 95

Slide 95 text

Let’s recap Color pipeline

Slide 96

Slide 96 text

Let’s recap sRGB input Color pipeline

Slide 97

Slide 97 text

Let’s recap sRGB input EOCF Color pipeline

Slide 98

Slide 98 text

Let’s recap sRGB input EOCF Linear input Color pipeline

Slide 99

Slide 99 text

Let’s recap sRGB input EOCF Linear input Processing Color pipeline

Slide 100

Slide 100 text

Let’s recap sRGB input EOCF Linear input Processing OECF Color pipeline

Slide 101

Slide 101 text

Let’s recap sRGB input EOCF Linear input Processing OECF Display Color pipeline

Slide 102

Slide 102 text

Questions