You are on page 1of 60

Lecture8

Introductionto
ColorImageProcessing
LinZHANG,PhD
SchoolofSoftwareEngineering
TongjiUniversity
Spring2013

LinZHANG,SSE,2013

Outline

Colorfundamentals
Colormodels
Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing

LinZHANG,SSE,2013

ColorFundamentals
In1666,IsaacNewtondiscoveredthatwhenabeam
ofsunlightpassesthroughaglassprism,the
emergingbeamissplitintoaspectrumofcolors

LinZHANG,SSE,2013

ColorFundamentals
Thecolorsthathumansandmostanimalsperceive
inanobjectaredeterminedbythenatureofthe
lightreflectedfromtheobject
Forexample,green
objectsreflectlight
withwavelengths
primarilyintherange
Wh
ite L
of500 570nmwhile
ight
Colours
absorbingmostofthe
Absorbed
energyatother
Light
Green
wavelengths
LinZHANG,SSE,2013

ColorFundamentals
Chromaticlightspanstheelectromagneticspectrum
fromapproximately400to700nm
Aswementionedbeforehumancolorvisionis
achievedthrough6to7millionconesineacheye

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

ColorModel

Thepurposeofacolormodelistofacilitatethe
specificationofcolorsinsomestandard
Inessence,acolormodelisaspecificationofa
coordinatesystemandasubspacewithinthatsystem
whereeachcolorisrepresentedbyasinglepoint
Mostcolormodelsareorientedeithertowardspecific
hardwareortowardapplications

LinZHANG,SSE,2013

RGBModel

Red,green,andblue,threeprimarycolors

Conecellsinhumaneyeareresponsibleforcolorvision
Familiar?

LinZHANG,SSE,2013

RGBModel

Red,green,andblue,threeprimarycolors

Approximately66%oftheseconesaresensitivetored
light,33%togreenlightand6%tobluelight
Absorptioncurvesforthedifferentconeshavebeen
determinedexperimentally
Forstandardization,theCIE(in1931)designatedred
(700nm),green(546.1nm)andblue(435.8nm)lightas
threeprimarycolors;theyaremixedtogenerateother
spectralcolors

Note:theCIEstandardisnotquiteconsistentwiththe
responsecurvesoftheconecells;thisisbecausethecurvesare
notavailabletill1965
LinZHANG,SSE,2013

RGBModel

Somenotesonprimarycolors

Havingthreespecificprimarywavelengthsforthepurpose
ofstandardizationdoesnotmeanthesethreeRGB
componentsactingalonecangenerateallspectrumcolors
Thewordprimary hasbeenwidelymisinterpretedto
meanthatthethreestandardprimaries,whenmixedin
variousintensityproportions,canproduceall visiblecolors
Whenthethreeprimariesarefixed,wecanapproximate
allthespectrumcolorsbymixingtheprimaries(usually
throughsubjectiveexperiments)

LinZHANG,SSE,2013

RGBModel

RGBmodel

ThismodelisbasedonaCartesiancoordinatesystem
Thecolorsubspaceofinterestisthecube,inwhichRGB
primaryvaluesareatthreecorners;blackisattheorigin
whilewhiteisatthecornerfarthestfromtheorigin

LinZHANG,SSE,2013

RGBModel

RGBmodel

AnRGBcolorimageisanarrayofcolorpixels,
M N 3
whereeachcolorpixelisatriplet,correspondingtothe
red,green,andbluecomponents
AnRGBimagemaybeviewedasastack ofthreegray
scaleimages

LinZHANG,SSE,2013

RGBModel

RGBmodel

Thethreecolor
componentsofa
colorpixel,arranged
asacolumnvector

Bluecomponentimage
Greencomponentimage
Redcomponentimage

LinZHANG,SSE,2013

RGBModel

RGBmodel

InMatlab,routinecat canbeusedtostackthreecomponents
toformanRGBimage

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

CMY(CMYK)Model

Theprimarycolors(R,G,B)canbeaddedtoproduce
thesecondary colors

Redplusbluecangeneratemagenta
Greenplusbluecangeneratecyan
Redplusgreencangenerateyellow

LinZHANG,SSE,2013

CMY(CMYK)Model

CMYcolorspace

Ittakescyan,magenta,andyellowasprimarycolors
CMYiswidelyusedforpaintingandprinting

CMYmodelcanbeeasilyconvertedfromRGBmodelby

C 1 R
M 1 G

Y 1 B
whereallcolorvalueshavebeennormalizedtotherange[0,1]

LinZHANG,SSE,2013

CMY(CMYK)Model

CMYcolorspace

Ittakescyan,magenta,andyellowasprimarycolors
CMYiswidelyusedforpaintingandprinting

ImplementationTips
1) ConversionbetweenRGBandCMYimagescanbeeasily
implementedviaimcomplement

LinZHANG,SSE,2013

CMY(CMYK)Model

CMYKcolorspace

Theoreticallyspeaking,equalamountsofpigments
primaries,cyan,magenta,andyellowshouldproduce
black
Inpractice,suchamethodcangenerateaquitemuddy
black
Thus,toproducetrueblack,afourthcolor,black is
addedandgivesrisetotheCMYKcolormodel.(Kmeans
blackinK)

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

HSIModel

Humaneyedistinguishonecolorfromtheother
basedonhue,saturation,andbrightness

Hue,isacolorthatisevokedbyasinglewavelengthoflight
inthevisiblespectrum,orbyarelativelynarrowbandof
wavelengths;huerepresentsdominantcolorasperceived
bytheobserver
Saturation(purity)referstotherelativeamountofwhite
lightmixedwithahue;itisinverselyproportionaltothe
amountofwhitelightadded;todesaturate acolorofgiven
intensityinasubtractivesystem(suchaswatercolor),one
canaddwhite,black,gray
Brightnessembodiestheachromaticnotionofintensity

LinZHANG,SSE,2013

HSIModel

Hueandsaturationtogetherarecalledchromaticity
Foranyparticularcolor,theamountsofred,green,
andblueneededtoformitarecalledtristimulus
values,andtheyaredenotedasX,Y,andZ

Acolorisspecifiedbyitstrichromatic coefficients,definedas
X
x
X Y Z
Y
y
X Y Z
Z
z
X Y Z
Ofcourse,
x y z 1
LinZHANG,SSE,2013

HSIModel

CIEchromaticity
diagram

Itisafunctionofx
(red)andy (green)
z canbederivedbyz =
1-x-y

LinZHANG,SSE,2013

HSIModel

SomenotesonCIEchromaticitydiagram

Anycolorlocatedontheboundaryofthechromaticitychart
isfullysaturated;anypointnotontheboundarybutwithin
thediagramrepresentssomemixtureofspectrumcolors
Thepointofequalenergyrepresentsthestandardwhite
light;itssaturationiszero
Asapointleavestheboundaryandapproachesthepointof
equalenergy,morewhitelightisaddedtothecolorandit
becomeslesssaturated
Astraightlinesegmentjoininganytwopointsinthediagram
definesallthedifferentcolorvariationsthatcanbeobtained
bycombiningthesetwocolorsadditively

LinZHANG,SSE,2013

HSIModel

TheHSImodelusesthreemeasurestodescribe
colors,hue,saturation,andintensity
Theirrelationshipcanberepresentedinacylindrical
coordinatesystem

anglearoundthecentralverticalaxiscorrespondsto
"hue",
thedistancefromtheaxiscorrespondsto"saturation",
thedistancealongtheaxiscorrespondsto"value"

LinZHANG,SSE,2013

HSIModel

IllustrationforHSImodelusingafigure

LinZHANG,SSE,2013

HSIModel

ConversionfromRGBtoHSI

if B G
H
360 if B G

1
R G R B

2
1
where, cos
R G2 R BG B

1
2

3
S 1
minR,G,B

R G B

1
3

R G B
LinZHANG,SSE,2013

HSIModel

ConversionfromHSItoRGB
RGsector(0 <= H < 120)

S cos H
B I 1 S R I 1
G 3I R B

cos 60 H
GBsector(120<= H < 240)

H H 120

S cos H
R I1 S G I 1
B 3I R G

cos 60 H

LinZHANG,SSE,2013

HSIModel

ConversionfromHSItoRGB
BRsector(240<= H <= 360)

H H 240
G I 1 S

S cos H

B I 1

cos 60 H

R 3I G B

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

NTSCModel

NTSC(NationalTelevisionStandardsCommittee)
colorsystemisusedinanalogtelevision
Inthisspace,grayscaleinformationisseparated
fromcolordata;sothesamesignalcanbeusedfor
bothcolorandmonochromeTVsets
Imagedataconsistsofthreecomponents,luminance
(Y),hue(I),andsaturation(Q)

LinZHANG,SSE,2013

NTSCModel

ConversionfromRGBtoYIQ
Y 0.299 0.587 0.114 R
I 0.596 0.274 0.322 G


Q 0.211 0.523 0.312 B
Especially,

Y 0.299 R 0.587G 0.114 B

ThisiswhatMatlab doeswhenyoucallrgb2gray

LinZHANG,SSE,2013

NTSCModel

ConversionfromYIQtoRGB
R 1.000 0.956 0.621 Y
G 1.000 0.272 0.647 I


B 1.000 1.106 1.703 Q
ImplementationTips
1) ConversionfromRGBtoYIQisimplementedinrgb2ntsc
2) ConversionfromYIQtoRGBisimplementedinntsc2rgb

LinZHANG,SSE,2013

NTSCModel

Anexample,anRGBimageanditsY,I,Qcomponents

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

YCbCr Model

YCbCr colorspaceisextensivelyusedindigitalvideo
Inthismodel,luminanceisrepresentedbyasingle
component,Y
Colorinformationisstoredastwocolordifference
components,Cb,andCr
Cb isthedifferencebetweenthebluecomponentand
areferencevalue;Cristhedifferencebetweenthered
componentandareferencevalue

LinZHANG,SSE,2013

YCbCr Model

ConversionfromRGBtoYCbCr
Y 16 65.481 128.553
Cb 128 37.797 74.203

Cr 128 112.000 93.786

24.966 R
112.000 G
18.214 B

ImplementationTips
1) ConversionfromRGBtoYCbCr isimplementedin
rgb2ycbcr
2) ConversionfromYCbCr toRGBisimplementedin
ycbcr2rgb

LinZHANG,SSE,2013

YCbCr Model

AnRGBimageanditsY,Cb,Crcomponents

LinZHANG,SSE,2013

Outline
Colorfundamentals
Colormodels
RGB
CMY(CMYK)
HSI
NTSC
YCbCr
CIEL*a*b*

Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing
LinZHANG,SSE,2013

CIEL*a*b*Model

CIEL*a*b*Model(proposedinCIE,1976)

TheL*a*b* systemisbasedonthethreedimensional
coordinatesystembasedontheopponenttheoryusing
blackwhiteL*,redgreena*,andyellowblueb*
components.
Itisperceptuallyuniform,whichmeansthatnumerical
distancescanberelatedtohumanperceptualdifferences
Itisdeviceindependent
L*a*b*valuesdonotdefineabsolutecolorsunlessthe
whitepointisalsospecified

LinZHANG,SSE,2013

CIEL*a*b*Model

CIEL*a*b*Model

TheL*a*b* coordinatesarecomputedfromtheX,Y andZ


tristimulus valuesasfollows:
Y
L* 116 f 16
Yn
X
Y
a * 500 f
f


X
Yn
n

b 200 f

Y
Z
f
Yn
Z n

3
1/3
6
t , if t

29
,where f (t )
2
1
29
4

t
, otherwise
3 6
29

Here Xn, Yn and Zn aretheCIEXYZtristimulus valuesofthe


reference whitepoint (thesubscriptn suggests"normalized")

LinZHANG,SSE,2013

CIEL*a*b*Model

CIEL*a*b*Model
ImplementationTips
1) ConversionsbetweenRGBandCIEL*a*b*canbe
implementedbymakecform andapplycform

Anexample,
imRGB =imread('gate1.bmp');
cform =makecform('srgb2lab','AdaptedWhitePoint',whitepoint('D65'));
imLab =applycform(imRGB,cform);

LinZHANG,SSE,2013

CIEL*a*b*Model

CIEL*a*b*Model

LinZHANG,SSE,2013

Outline

Colorfundamentals
Colormodels
Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing

LinZHANG,SSE,2013

Pseudocolour ImageProcessing

Pseudocolour imageprocessingconsistsofassigning
colorstogreyvaluesbasedonaspecificcriterion
Theprincipleuseofpseudocolour imageprocessing
isforhumanvisualization
Humanscandiscernbetweenthousandsofcolorshades
andintensities,comparedtoonlyabouttwodozenorso
shadesofgrey

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing

Intensityslicingandcolorcodingisoneofthesimplest
kindsofpseudocolour imageprocessing

Firstweconsideranimageasa3Dfunctionmapping
spatialcoordinatestointensities(thatwecanconsider
heights)
Nowconsiderplacingplanesatcertainlevelsparallelto
thecoordinateplane
Ifavalueisonesideofsuchaplaneitisrenderedinone
color,andadifferentcolorifontheotherside

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing

Intensityslicingandcolorcodingisoneofthesimplest
kindsofpseudocolour imageprocessing

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing

Intensityslicingandcolorcodingisoneofthesimplest
kindsofpseudocolour imageprocessing

Ingeneralintensityslicingcanbesummarizedas:
Let[0, L-1]representthegreyscale
Letl0 representblack[f(x, y) = 0]andletlL-1 represent
white[f(x, y) = L-1]
SupposeP planesperpendiculartotheintensityaxisare
definedatlevelsl1, l2, , lp
Assumingthat0 < P < L-1, thentheP planespartitionthe
greyscaleintoP + 1 intervalsV1, V2,,VP+1

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing


Greylevelcolorassignmentscanthenbemade
accordingtotherelation:

f (x, y) c k

if f (x, y) Vk

whereck isthecolorassociatedwiththekth intensitylevelVk


definedbythepartitioningplanesatl = k 1 and l = k

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing


Anexample

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing


Anotherexample

LinZHANG,SSE,2013

Pseudocolour ImageProcessing IntensitySlicing


Onemoreexample

LinZHANG,SSE,2013

Outline

Colorfundamentals
Colormodels
Pseudocolor imageprocessing
Basicsoffullcolorimageprocessing

LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Fullcolorimageprocessingapproachesfallintotwo
majorcategories

Inthefirstcategory,weprocesseachcomponentimage
individuallyandthenformacompositeprocessedcolor
imagefromtheindividuallyprocessedcomponents
Inthesecondcategory,weworkwithcolorpixelsdirectly

LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Colortransformations

Colortransformationscanbeoftheform

si Ti ri , i 1, 2,..., n
whereri andsi arethecolorcomponentsoftheinputandoutput
images,n isthedimensionofthecolorspace.Ti arereferredto
asfullcolortransformation ormappingfunctions

LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Colortransformations

(a)(b)

(c)(d)

Examplesforcolormapping
functions.(a)and(c)arelinear
interpolation;(b)and(d)are
cubicspline interpolation
LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Colortransformations

ImplementationTips
1) Linearinterpolationbyusingcontrolpointsis
implementedininterp1q
2) Cubicspline interpolationbyusingcontrolpointsis
implementedinspline

LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Colortransformations

Gonzalezprovidesaninteractivecoloreditor,seeourcourse
website
Itimplementsthecolortransformationfunctions
Italsoprovidesanexcellentdemoforhowtodevelop
applicationwithGUIsinMatlab

Sourcecodeisavailableonourcoursewebsite

LinZHANG,SSE,2013

BasicsofFullColorImageProcessing

Colortransformations

GUIforice
LinZHANG,SSE,2013

Thanksforyourattention

LinZHANG,SSE,2013

You might also like