26
18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction to Computer Graphics Color (2) Chapter 19 Min H. Kim KAIST School of Computing Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 SUMMARY Color (1) 2

CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CS380:IntroductiontoComputerGraphicsColor(2)Chapter19

MinH.KimKAISTSchoolofComputing

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

SUMMARYColor(1)

2

Page 2: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

2

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorBases•  Wecaninsertany(nonsingular)3-by-3matrixManditsinversetoobtain:

3

!c(l(λ))= !c(l436)!c(l546)

!c(l700)⎡⎣

⎤⎦M

−1( ) Mk436(λ)l(λ)dλΩ∫k546(λ)l(λ)dλΩ∫k700(λ)l(λ)dλΩ∫

⎢⎢⎢⎢

⎥⎥⎥⎥

⎜⎜⎜⎜⎜

⎟⎟⎟⎟⎟

=!c1!c2!c3

⎡⎣

⎤⎦

k1(λ)l(λ)dλΩ∫k2(λ)l(λ)dλΩ∫k3(λ)l(λ)dλΩ∫

⎢⎢⎢⎢

⎥⎥⎥⎥

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorBases•  Wherethedescribeanewcolorbasisdefinedas

•  Thek(λ)functionsformthenewassociatedmatchingfunctions,definedby:

4

!c1!c2!c3

⎡⎣

⎤⎦=

!c(l436)!c(l546)

!c(l700)⎡⎣

⎤⎦M

−1 ci

k1(λ)k2(λ)k3(λ)

⎢⎢⎢⎢

⎥⎥⎥⎥

=Mk436(λ)k546(λ)k700(λ)

⎢⎢⎢⎢

⎥⎥⎥⎥

Page 3: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

3

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Howdoescomputationwork?

•  Illuminationonasurfacecolor(element-by-elementproduct)

•  Reflectedcolor

•  ThreeCMFsforXYZ

•  Trichromaticresponseasscalar(sumofenergy)

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

COLOR(2)Chapter19

6

Page 4: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

4

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RememberThisColor

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Mapofcolorspace(lassocurve)

8

LassocurveinLMScoordinates

NormalizedlassocurveinLMScoordinates

Page 5: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

5

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Mapofcolorspace(lassocurve)•  Asweletλvary,suchvectorswilltraceoutalassocurveinspace.

•  Thelassocurveliescompletelyinthepositiveoctantsinceallresponsesarepositive.

•  Thecurvebothstartsandendsattheoriginsincetheseextremewavelengthsareattheboundariesofthevisibleregion,beyondwhichtheresponsesarezero.

•  ThecurvespendsashorttimeontheSaxis(shownwithbluetintedpoints)

9

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Mixedinvisible•  Aswelookatallpossiblemixedbeams,the

resultingcoordinatessweepoutsomesetofvectorsin3Dspace.

•  Sincecanbeanypositivefunction,thesweptsetiscomprisedofallpositivelinearcombinationsofvectorsonthelassocurve.

•  Thus,thesweptsetistheconvexconeoverthelassocurve,whichwecallthecolorcone.

•  Vectorsinsidetheconerepresentactualachievablecolorsensations.

•  Vectorsoutsidethecone,suchastheverticalaxisdonotarisethesensationfromanyactuallightbeam,whetherpure(monochromatic)orcomposite

10

l(λ)[L,M ,S]t

l(λ)

Page 6: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

6

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CIEXYZcolorspacein3D•  Centralstandardizedspace.•  Specifiedbythethreematchingfunctionscalled

•  Thecoordinatesforsomecolor(aspectrum)withrespecttothisbasisisgivenbyacoordinatevectorthatwecall.

•  Theseparticularmatchingfunctionswerechosensuchthattheyarealwayspositive,andsothattheY-coordinateofacolorpresentsitsoverallperceived“luminance”.ThusYisoftenusedasablackandwhiterepresentationofthecolor.

•  Theassociatedbasisismadeupofthreeimaginarycolors;theaxesareoutsideofthecolorcone. 11

kx(λ),ky(λ)andkz(λ)

[X ,Y ,Z ]t

[cx ,cy ,cz ]

t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

HowtocomputeCIEXYZ

•  Emittingcolors(radiance)– SincewehavethespectralpowerdistributionsofradianceL(powerperwavelength)

X =Km L(λ)x(λ)Δλλ

∑ ,

Y =Km L(λ)y(λ)Δλ ,λ

Z =Km L(λ)z(λ)Δλ ,λ

whereKm = 683lm/W .– HeretheYvaluecorrespondstoluminance(cd/sqm)

Noticethedifference!

Page 7: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

7

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RECAP:CIEXYZcomputation

•  Illuminationonasurfacecolor(element-by-elementproduct)

•  Reflectedcolor

•  ThreeCMFsforXYZ

•  Trichromaticresponseasscalar(sumofenergy)X Y

Z

CIECMFs

Reflection

ReflectanceIllumination

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Reflectionmodeling•  Whenabeamoflightfromanilluminationsourcehitsasurfaceofareflectancefunction

•  Thismultiplicationhappensonaper-wavelengthbasis.Metamerismhappensinourbrain.

•  A3Dcolorrenderingcannothandlethis;instead,weneedtousemultispectralorhyperspectralrendering.

14

i(λ)r(λ)

l(λ) = i(λ)r(λ)

!c[i1(λ)ra(λ)]=

!c[i1(λ)rb(λ)]⇔ !c[i2(λ)ra(λ)]=!c[i2(λ)rb(λ)]

Page 8: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

8

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

HowtocomputeCIEXYZ

•  Relativereflectivecolors– SincewehavethespectralpowerdistributionsofilluminationIandsurfacereflectanceR

X =k I(λ)R(λ)x(λ)Δλλ

∑ ,

Y =k I(λ)R(λ)y(λ)Δλ ,λ

Z =k I(λ)R(λ)z(λ)Δλ ,λ

wherek = 100I(λ)y(λ)Δλ

λ

∑. NotethereisnoR(λ)inthedenominator!

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Chromaticityxyin2D•  2Dplotforchromaticinformation•  What’sleftafterluminanceisfactoredout(thecolorwithoutregardforoverallluminance),thereforecommonlycoupledwithY

x = XX +Y + Z

,

y = YX +Y + Z

,

z = ZX +Y + Z

,

x + y + z = 1

Page 9: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

9

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Chromaticityxyin2D•  Scalesofvectorsintheconecorrespondtobrightnesschangesinourperceivedcolorsensation,soletsnormalizebyscale.

17

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Chromaticityxyin2D

•  Spectrallocus–  lassoin2D– Plotmonochromaticlightsinthevisiblespectrum(400-700nm)

•  Isthisdiagramperfectforrepresentingcolors?

Page 10: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

10

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

UniformChromaticityu’v’

•  Chromaticityxyismathematicallyconvenient,notsuitableforevaluatingcolorinformationduetonon-uniformity

CIE1931xy CIE1976u’v’

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

UniformChromaticityu’v’

•  CIT1976chromaticitycoordinatesu’v’•  aregivenby

u ' = 4X / (X +15Y + 3Z )= 4x / (−2x +12y + 3)

v ' = 9Y / (X +15Y + 3Z )= 9y / (−2x +12y + 3)

Page 11: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

11

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CorrelatedColorTemperaturein1D

•  Real-worldilluminantcanbeapproximatedasacolortemperatureofPlanckianblackbodyradiation(=thesun)

•  Theclosestcolortemperatureontheblackbodylocusofthereal-worldilluminantiscalledcorrelatedcolortemperature(CCT)

•  Unit:Kelvin

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

DeviceDependentColorSpaces•  Exampe:RGBvalues•  Pros:–  Simpledescriptionofcolorforthedevice

– Natural,easywaytospecifycolortotheuser

•  Cons:–  Cannotcomparecolorsbetweendevices

– Notperceptuallyuniform

Page 12: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

12

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Perceptualcolorspacein3D•  WeonlydrawcolorsinthegamutoftheRGBmonitor

•  Colorsalongtheboundaryoftheconearevividandareperceivedas“saturated”.

•  Aswecirclearoundtheboundary,wemovethroughthedifferent“hues”ofcolor.

•  StartingfromtheLaxis,wemovealongtherainbowcolorsfromredtogreentoviolet.– Achievablebymonochromaticbeams.

23

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Perceptualcolorspacesin3D•  Colorcone’sboundaryhasaplanarwedge(alinesegmentinthe2Dfigure).– Thecolorsonthiswedgearethepinksandpurples.– Theydonotappearintherainbowandcanonlybeachievedbyappropriatelycombiningbeamsofredandviolet.

•  Aswemoveinfromtheboundarytowardsthecentralregionofthecone,thecolors,whilemaintainingtheirhue,de-saturate,becomingpastelandeventuallygrayishorwhitish.

24

Page 13: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

13

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

DeviceIndependentColorSpaces

•  Pros:– Basedonhumanvisualperception– Colorspecificationindependentofdevice–  Interchangeablecoloramongdevices– Comparison,computationofsmallcolordifferences

•  Cons:– CIEXYZ:notuniform– CIELAB,CIELUV,CIEXYZ,Munsell:alldependentontheilluminant

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Perceptualcolorspacesin3D•  Uniformperceptualdistanceofdifferentcolors

•  Opponentprimaries•  Threedimensions:lightness,colorfulness,andhue(L,C,H)

•  Relatedtoprocessesofhumanvisualperception

•  Meaningfulwayofdescribingcolor

Page 14: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

14

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

HSVColorSpace•  notperceptuallydriven!•  Value:

•  Saturation:•  Hue:

V = M = max(R,G,B).

m = min(R,G,B),C = M −m,S = C /V ,

H =360 + 60(G − B) /C if M = R120 + 60(B − R) /C240 + 60(R −G) /C

if M = Gif M = B

⎨⎪

⎩⎪

JacobRu

s

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

MunsellSystem(1915)•  Fiveprimaryhues:•  Valuerange:•  Chromarange:

YellowRed Green Blue Purple

…0 5 … ∞

10RP4/10=aspecificreddishpurplehueof10RP,avalueof4,andachromaof10

… 105…0

Page 15: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

15

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CIEUniformColorSpaces(1976)•  OriginatedfromHunterLab1948•  Perceptuallyuniformcolordefinition

•  DrivenfromCIEXYZ

L*=43.31a*=47.63b*=14.12

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CIELABMath•  Simplifiedconeresponse(XYZandacubicrootfunc.)•  Coloropponenttheoryforcomputingchromaandhue•  Lightness:•  Coloropponents:

•  Chroma:•  Hue:

L* =116 f (Y /Yn)−16,a* = 500[ f (X / Xn )− f (Y /Yn )],

b* = 200[ f (Y /Yn )− f (Z / Zn )],

Cab* = (a*)2 + (b*)2 ,

hab = tan−1(b* / a*).

f (x) = x1/3, x > 0.0088567.787x +16 /116, x ≤ 0.008856

⎧⎨⎪

⎩⎪

Page 16: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

16

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RememberThisColor

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorDifferences

•  ConventionalEuclideanmetricinaperceptuallyuniformcolorspace(CIELAB)

ΔEab* = ΔL*( )2 + Δa*( )2 + Δb*( )2

CIE ΔEab*

L*

b*

a*

Page 17: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

17

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

sRGBcolorspace•  ThereareavarietyofRGBstandards.•  CurrentoneiscalledRec.709RGBspace(so-calledsRGB).

•  Basisismadeupofthreeactualcolorsintendedtomatchthecolorsofthethreephosphorsofanidealmonitor/TVCRT(cathoderaytube)display.

•  Colorswithnon-negativeRGBcoordinatescanbeproducedonamonitorandaresaidtolieinsidethegamutofthecolorspace.Thesecolorsareinthefirstoctantofthefigure.

33

[cr ,cg ,cb ]

t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

sRGBvs.Pointer’sgamut•  SomeactualcolorslieoutsidethesRGBgamut.

•  Additionally,onamonitor,eachphosphormaxesoutat“1”,whichalsolimitstheachievableoutputs.

•  Imageswithcolorsoutsidethegamutneedsomekindofmapping/clippingtokeepinthegamut,so-calledgamutmapping.

34

Rec.709/sRGBvs.Pointer’sgamut(69.4%ofPointer’sgamut)

http://www.tftcentral.co.uk/articles/pointers_gamut.htm

Page 18: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

18

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

XYZvs.sRGB

35

CIEXYZ sRGB

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Gammacorrection

•  InheritedfromthetonereproductioncurveoftheCRTphosphors

•  Tocompensatenon-linearresponse(^2.2)ofthedisplay,apply(^1/2.2)tothedisplaysignals(sRGB)

•  Computationalredundancy(replacedwithLUT)

•  RemovedfromHDTVsignals

Page 19: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

19

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Gammacorrection•  Eachpixelonadisplayisdrivenbythreevoltages,say.

•  Lettingtheoutgoinglightfromthispixelhaveacolorwithcoordinates

•  Wewanttoobtainsomespecificoutputfromapixel,thenweneedtodriveitwithvoltages:

•  valuesarecalledthegammacorrectedRGBcoordiantes.

37

( ′R , ′G , ′B )

[R,G,B]t

R=( ʹR )2.2 ,G =( ʹG )2.2 ,B =( ʹB )2.2

[R,G,B]t

ʹR =(R)0.45 , ʹG =(G)0.45 , ʹB =(B)0.45

[ ′R , ′G , ′B ]t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Gammacorrection•  Linearvs.gamma-corrected

38

Linear

Gamma-corrected

Page 20: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

20

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

NonlinearSRGBtolinearXYZ?

•  (Step1)NormalizeRGBvalues•  (Step2)Inversegammacorrection(γ=2.2)

•  (Step3)TransformationfromsRGBtoCIEXYZ•  sRGBàXYZ

•  (cf)Inv.Trans:XYZàsRGB

XYZ

⎢⎢⎢

⎥⎥⎥=

0.4124 0.3576 0.18050.2126 0.7152 0.07220.0193 0.1192 0.9505

⎢⎢⎢

⎥⎥⎥

RGB

⎢⎢⎢

⎥⎥⎥

RGB

⎢⎢⎢

⎥⎥⎥=

3.2406 −1.5372 −0.4986−0.9689 1.8758 0.04150.0557 −0.2040 1.0570

⎢⎢⎢

⎥⎥⎥

XYZ

⎢⎢⎢

⎥⎥⎥

R=( ʹR )2.2 ,G =( ʹG )2.2 ,B =( ʹB )2.2

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Quantization•  sRGBcoordinatesareintherealrange[0…1]•  Afixedpointrepresentationisusedwithvalues[0…255](8-bitcolor)àunsignedcharinC

40

(realàbyte)byteR=round(realR*255);(byteàreal)realR=byteR/255.0;

(realàbyte)byteR=round(realR>=1.0?255:(realR*256)–0.5);(byteàreal)realR=(byteR+0.5)/256.0;e.g.:(realàbyte)0=round(0.7–0.5);1=round(1.0–0.5)

Page 21: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

21

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorsinGLSL•  Imagesaretypicallystoredingammacorrectedcoordinates,andthemonitorscreenisexpectingcolorsingammacorrectedcoordinates.

•  Computergraphicssimulatesprocessesthatarelinearlyrelatedtolightbeams.Assuch,mostcomputergraphicscomputationsshouldbedoneinalinearcolorrepresentation.

•  Inprofessionalcomputergraphics,weuselinearHDRradianceintheformatofOpenEXR

41

[R,G,B]t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorsinGLSL•  ByusingthecallglEnable(GL_FRAMEBUFF_SRGB),•  Wecanpasslinearvaluesoutfromthefragmentshader,andtheywillbegammacorrectedintothesRGBformatbeforebeingsenttothescreen.

•  glTexImage2D(GL_TEXTURE_2D,0,GL_SRGB,twidth,theight,0,GL_RGB,GL_UNSIGNED_BYTE,pixdata)

•  Then,wheneverthistextureisaccessedinafragmentshader,thedataisfirstconvertedtolinearcoordinatesbeforegiventotheshader.

42

[R,G,B]t

[R,G,B]t

Page 22: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

22

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Colorconstancy•  Althoughthespectralpowerdistributionofsceneilluminationchanges,wecanperceivecolors(reflective)consistently,so-calledcolorconstancy

•  Thisvisualphenomenonisimplementedaswhitebalancingindigitalcameras.

•  ThisisoftenimplementedasavonKriestransformintheLMSorXYZspacefromagivenilluminationtoatargetillumination.

43

i1(λ)i2 (λ)

M =

L2 /L1 0 00 M2 /M1 00 0 S2 /S1

⎢⎢⎢⎢

⎥⎥⎥⎥

whereL1 ,M1 ,S1 aretheconeresponsesundergiveni1(λ),L2 ,M2 ,S2 aretheconeresponsesundertargeti2(λ).

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Colorimetriccalculation

•  AllcolorimetricvaluesarecomputedfromCIEXYZ

Radiance Reflectance CIEXYZ CIELuv

CIELAB

xy

sRGB

Drgb

Energyperunitareapersolidangle

Energyatagivenangle,relativetoenergyreflectedbyperfectdiffuser

Relativeamountsofthreeimaginaryprimariesrequiredtomatchthecolorappearance

Page 23: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

23

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproduction•  Imaginewehaveaspectrums;wanttomatchonRGBdisplay

•  Practically,wecannotachieveaphysicallyidenticalspectrumbecausetheyaredifferentmedia

•  Butcouldfindaspectrumsathatthedisplaycanproduce,whichisametamerofs

ssa

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

•  WewanttocomputesathecombinationofR,G,B

•  whichwillprojecttothesamevisualresponseass

•  sawillbeametamerofs

RGB

XYZ

Spanofeye’sspectralresponsefunctions

Spanofdisplay’sprimaries

Adap

tedfrom

SteveM

arschn

er

Visualresponsetosandsa

Spectrums

Spectrumsa C

V

Page 24: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

24

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

•  Theprojectionontothethreeresponsefunctionscanbewritteninamatrixform:

•  or,

XYZ

⎢⎢⎢

⎥⎥⎥= rX rY

rZ

⎢⎢⎢

⎥⎥⎥

s

⎢⎢⎢

⎥⎥⎥.

SpectralresponsivityofXYZ

V = MXYZs.

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

•  ThespectrumthatisproducedbythedisplayforthecolorsignalsR,G,Bis:

•  Againthediscreteformcanbewrittenasamatrix:

•  or,

Sa (λ) = Rsr (λ)+Gsg (λ)+ Bsb (λ).

sa

⎢⎢⎢

⎥⎥⎥=

sR sG sB

⎢⎢⎢

⎥⎥⎥

RGB

⎢⎢⎢

⎥⎥⎥.

sa = MRGBC.SpectraofRGBphosphors

Page 25: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

25

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

•  Whatcolordoweseewhenwelookatthedisplay?

•  FeedC(R,G,B)todisplay•  Displayproducessa•  EyeslookatsaandproduceV

V = MXYZMRGBC.

XYZ

⎢⎢⎢

⎥⎥⎥=

rX ⋅ sR rX ⋅ sG rX ⋅ sBrY ⋅ sR rY ⋅ sG rY ⋅ sBrZ ⋅ sR rZ ⋅ sG rZ ⋅ sB

⎢⎢⎢

⎥⎥⎥

RGB

⎢⎢⎢

⎥⎥⎥.

RGB

XYZ

saC

V

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

•  Goalofreproduction:visualresponsetosandsaisthesame:

•  Substitutingintheexpressionforsa,

MXYZ s = MXYZ sa .

MXYZ s = MXYZMRGBC.

C = (MXYZMRGB )−1MXYZ s.

Colorreproductionmodelfordisplay

RGB

XYZ sa≈s

s

saC

V

Page 26: CS380: Introduction to Computer Graphics Color (2) Chapter ... · 18/05/17 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction

18/05/17

26

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

ColorReproductionasLinearAlgebra

RGB

XYZ

Spanofeye’sspectralresponsefunctions

Spanofdisplay’sprimaries

Visualresponsetosandsa

Spectrums

Spectrumsa C

V

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Wherearethecolortransforms?

•  Nowadays,ineverydigitalimagingdevices:– TV,digitalcameras,camcorders,inkjetprinters,laserprinters,LCDdisplays,etc…

•  Otherwise…