Digial image processing IMAGE SAMPLING AND IMAGE QUANTIZATION. Inrodcion. Sampling in he wo-dimensional space Basics on image sampling The concep of spaial freqencies Images of limied bandwidh Two-dimensional sampling Image reconsrcion from is samples The Nqis rae. The alias effec and specral replicas sperposiion The sampling heorem in he wo-dimensional case Non-recanglar sampling grids and inerlaced sampling The opimal sampling Pracical limiaions in sampling and reconsrcion 3. Image qanizaion 4. The opimal qanizer The niform qanizer 5. Visal qanizaion Conras qanizaion Psedo-random noise qanizaion Halfone image generaion Color image qanizaion
Digial image processing. Inrodcion f f s mn Sampling Qanizaion Comper Digiizaion Comper mn D/A conversion Displa Analog displa Fig Image sampling and qanizaion / Analog image displa
Digial image processing. Sampling in he wo-dimensional space Basics on image sampling f
Digial image processing The concep of spaial freqencies - Gre scale images can be seen as a -D generalizaion of ime-varing signals boh in he analog and in he digial case; he following eqivalence applies: -D signal ime varing -D signal gre scale image Time coordinae Insananeos vale: f A -D signal ha doesn var in ime is consan = has A.C. componen and onl a D.C. componen The freqenc conen of a -D signal is proporional o he speed of variaion of is insananeos vale in ime: ν ma ~ madf/d Discree -D signal: described b is samples => a vecor: =[ N-] N samples; he posiion of he sample = he discree ime momen The specrm of he ime varing signal = he real par of he Forier ransform of he signal Fω; ω=πν. Space coordinaes Brighness level poin-wise: f A perfecl niform image i has he same brighness in all spaial locaions; he D.C. componen = he brighness in an poin The freqenc conen of an image -D signal is proporional o he speed of variaion of is insananeos vale in space: ν ma ~ madf/d; ν ma ~ madf/d => ν ma ν ma = spaial freqencies Discree image -D signal: described b is samples b in -D => a mari: U[M N] U={mn} m= M-; n= N-. The specrm of he image = real par of he Forier ransform of he image = -D generalizaion of -D Forier ransform Fω ω ω =πν ; ω =πν
Digial image processing Images of limied bandwidh Limied bandwidh image = -D signal wih finie specral sppor: Fν ν = he Forier ransform of he image: F j j f e e dd f Fν ν e j dd. F ν ν ν ν -ν ν ν ν -ν The Forier ransform of he limied specrm image -ν The specral sppor region The specrm of a limied bandwidh image and is specral sppor
Two-dimensional sampling m n s n m n m f g f f Digial image processing The common sampling grid = he niforml spaced recanglar grid: m n n m g Image sampling = read from he original spaiall coninos brighness fncion f onl in he blac dos posiions onl where he grid allows:. Z m n oherwise n m f f s
Qesion: How o choose he vales Δ Δ o achieve: -he represenaion of he digial image b he min. nmber of samples -a ideall no loss of informaion? I. e.: for a perfecl niform image onl sample is enogh o compleel represen he image => sampling can be done wih ver large seps; on he opposie if he brighness varies ver sharpl => ver man samples needed The sampling inervals Δ Δ needed o have no loss of informaion depend on he spaial freqenc conen of he image. Sampling condiions for no informaion loss derived b eamining he specrm of he image b performing he Forier analsis: The sampling grid fncion g Δ Δ is periodical wih period Δ Δ => can be epressed b is Forier series epansion: Two-dimensional sampling. Forier ransform : dd e e g f dd e e f F g f f j j j j S S s Digial image processing l j j l l j j dd e e g l a e e l a g. where :
Since: Therefore he Forier ransform of f S is: The specrm of he sampled image = he collecion of an infinie nmber of scaled specral replicas of he specrm of he original image cenered a mliples of spaial freqencies /Δ / Δ. Two-dimensional sampling 3. l S l l j j S l j j l S j j l j j l S l F F dd e e f F dd e e f F dd e e e e f F Digial image processing. ; [; [; for l l a oherwise if g
Digial image processing Original image Original image specrm 3D Original image specrm D -D recanglar sampling grid Sampled image specrm 3D Sampled image specrm D
Digial image processing Image reconsrcion from is samples s s - 3 / / s s H s s oherwise ~ F H Fs F s - s ~ s f h fs Fig.4 The sampled image specrm ~ f fs m n Le s assme ha he filering region R is recanglar a he middle disance beween wo specral replicas: s s and sin s sin s H s s h s s oherwise ~ sin s m sin s n f f s m n h m n f s m n m n m n s m s n m nh m n
Digial image processing ~ f f s m n m nsinc msinc n where sinca s s sin a a Since he sinc fncion has infinie een => i is impossible o implemen in pracice he ideal LPF i is impossible o reconsrc in pracice an image from is samples wiho error if we sample i a he Nqis raes. Pracical solion: sample he image a higher spaial freqencies + implemen a real LPF as close o he ideal as possible. -D sinc fncion -D sinc fncion
Digial image processing The Nqis rae. The aliasing. The fold-over freqencies s s The Moire effec Fig. 5 Aliasing fold-over freqencies Noe: Aliasing ma also appear in he reconsrcion process de o he imperfecions of he filer! How o avoid aliasing if canno increase he sampling freqencies? B a LPF on he image applied prior o sampling! Jagged bondaries
Digial image processing Non-recanglar sampling grids. Inerlaced sampling grids -/ / ν / -/ Fν ν = / ν n - 3 m n - - m a Image specrm b Recanglar grid G c Inerlaced grid G - d The specrm sing G e The specrm sing G Inerlaced sampling Opimal sampling = Karhnen-Loeve epansion: f a m n m n m n
Digial image processing Image reconsrcion from is samples in he real case The qesion is: wha o fill in he inerpolaed new dos? Several inerpolaion mehods are available; ideall sinc fncion in he spaial domain; in pracice simpler inerpolaion mehods i.e. approimaions of LPFs.
Digial image processing Image inerpolaion filers: The -D inerpolaion fncion Graphical represenaion p The -D inerpolaion fncion p a =pp Freqenc response p a p a Recanglar zero-order filer p -/ / / rec p p sinc sinc 4 Trianglar firs order filer p - / ri p p p p sinc sinc 4 n-order filer n= qadraic n=3 cbic spline p n p p n convol@ii pn pn sinc sinc n 4 Gassian p g ep ep ep Sinc sinc sinc sinc rec rec
Digial image processing Image inerpolaion eamples:. Recanglar zero-order filer or neares neighbor filer or bo filer: / -/ / Original Sampled Reconsrced
Digial image processing Image inerpolaion eamples:. Trianglar firs-order filer or bilinear filer or en filer: / - Original Sampled Reconsrced
Digial image processing Image inerpolaion eamples: 3. Cbic inerpolaion filer or bicbic filer begins o beer approimae he sinc fncion: Original Sampled Reconsrced
Digial image processing Pracical limiaions in image sampling and reconsrcion Inp image Scanning ssem aperre p s -- g Real scanner model Ideal sampler g s Analog displa p a -- g ~ Fig. 7 The bloc diagram of a real sampler & reconsrcion displa ssem P a Inerpolaion filer or displa ssem specrm - s / s / Sampled image specrm Reconsrced image specrm Inp image specrm Specral losses - - s / s / Inerpolaion error Fig. 8 The real effec of he inerpolaion
Digial image processing 3. Image qanizaion 3.. Overview Qanizer r L Qanizer s op r + L+ r Qanizaion error r Fig. 9 The qanizer s ransfer fncion
Reconsrcion levels Digial image processing 3.. The niform qanizer The qanizer s design: Denoe he inp brighness range: Le B he nmber of bis of he qanizer => L= B reconsrcion levels The epressions of he decision levels: l min ; L Ma E.g. B= => L=4 Uniform qanizer ransfer fncion lmin ; L L Ma consan q L L Ma l q q q min L L The epressions of he reconsrcion levels: r4=4 r3=6 r=96 r=3 r q r = =64 3=8 4=9 5=56 Decision levels Compaion of he qanizaion error: for a given image of size M N piels U non-qanized and U qanized => we esimae he MSE: MN M N m n m n ' m n L r hlin U d
Reconsrcion levels Digial image processing Eamples of niform qanizaion and he resling errors: B= => L= Uniform qanizer ransfer fncion Non-qanized image Qanized image r=9 r=64 = =8 3=56 Decision levels Qanizaion error; MSE=36. 9 8 7 6 5 4 3 5 5 5 The hisogram of he non-qanized image
Reconsrcion levels Digial image processing Eamples of niform qanizaion and he resling errors: B= => L=4 Non-qanized image Uniform qanizer ransfer fncion Qanized image r4=4 r3=6 r=96 r=3 = =64 3=8 4=9 5=56 Decision levels Qanizaion error; MSE=5 9 8 7 6 5 4 3 5 5 5 The hisogram of he non-qanized image
Reconsrcion levels Digial image processing Eamples of niform qanizaion and he resling errors: B=3 => L=8; false conors presen r8=4 Uniform qanizer ransfer fncion Non-qanized image Qanized image r7=8 r6=76 r5=44 r4= r3=8 r=48 r=6 = =3 3=64 4=96 5=8 6=6 7=9 8=4 9=56 Decision levels 9 Qanizaion error; MSE=7.33 8 7 6 5 4 3 5 5 5 The hisogram of he non-qanized image
3.. The opimal MSE qanizer he Llod-Ma qanizer L d h ' ] ' E[ e L i i i i d h r L d h r r h r r r r E d h d h r p p j j j j j j Digial image processing 3 / 3 / ] [ ] [ d h d h A L z
Digial image processing L L [ h ] / 3 d 3 p j j+ L+ h ep Gassian or h ep variance - mean Laplacian
Nivelele de reconsrcie Digial image processing Eamples of opimal qanizaion and he qanizaion error: B= => L= Fncia de ransfer a canizorli opimal Non-qanized image Qanized image r=53 r=4 = =89 3=56 Nivelele de decizie 9 8 7 6 5 4 3 5 5 5 The non-qanized image hisogram The qanizaion error; MSE=9.5 38 36 34 3 3 8 6 4 The evolion of MSE in he opimizaion saring from he niform qanizer 8 3 4 5 6 7 8
Nivelele de reconsrcie Digial image processing Eamples of opimal qanizaion and he qanizaion error: B= => L=4 Fncia de ransfer a canizorli opimal Non-qanized image Qanized image r4=8 r3=56 r=5 r= = =68 3=36 4=69 5=56 Nivelele de decizie 9 8 The qanizaion error; MSE=9.6 The evolion of MSE in he opimizaion saring from he niform qanizer 7 6 5 4 3 5 4 3 5 5 5 The non-qanized image hisogram 9 3 4 5 6 7 8 9
Nivelele de reconsrcie Digial image processing Eamples of opimal qanizaion and he qanizaion error: B=3 => L=8 Non-qanized image Qanized image Fncia de ransfer a canizorli opimal r8=4 r7=8 r6=65 r5=47 r4=5 r3= r=54 r=4 = =34 3=78 4=3 5=36 6=567=73 8=3 9=56 Nivelele de decizie 9 8 7 6 5 4 3 5 5 5 The non-qanized image hisogram The qanizaion error; MSE=5 The evolion of MSE in he opimizaion saring from he niform qanizer 7.5 7 6.5 6 5.5 5 4.5 4 6 8 4
Digial image processing 3.3. The niform qanizer = he opimal qanizer for he niform gre level disribion: L h L oherwise r q L L consan q q q r q q/ q/ d q B herefore SNR log B 6 B db
Digial image processing 3.4. Visal qanizaion mehods In general if B<6 niform qanizaion or B<5 opimal qanizaion => he "conoring" effec i.e. false conors appears in he qanized image. The false conors conoring = grops of neighbor piels qanized o he same vale <=> regions of consan gra levels; he bondaries of hese regions are he false conors. The false conors do no conribe significanl o he MSE b are ver disrbing for he hman ee => i is imporan o redce he visibili of he qanizaion error no onl he MSQE. Solions: visal qanizaion schemes o hold qanizaion error below he level of visibili. Two main schemes: a conras qanizaion; b psedo-random noise qanizaion Uniform qanizaion B=4 Opimal qanizaion B=4 Uniform qanizaion B=6
Digial image processing 3.4. Visal qanizaion mehods a. Conras qanizaion The visal percepion of he lminance is non-linear b he visal percepion of conras is linear niform qanizaion of he conras is beer han niform qanizaion of he brighness conras = raio beween he lighes and he dares brighness in he spaial region js noiceable changes in conras: % => 5 qanizaion levels needed 6 bis needed wih a niform qanizer or 4-5 bis needed wih an opimal qanizer Brighness f brighnessconras c MMSE qanizer c f - conras - brighness c ln ; p. or c ; p. ; / 3 6...8 / ln
Reconsrcion levels Digial image processing Eamples of conras qanizaion: For c= /3 : 5 The ransfer fncion of he conras qanizer.9.8.7.6 5.5.4.3. 5....3.4.5.6.7.8.9 =3.9844 = 3=3.875 4=7.578 5=55 Decision levels 9 8 7 6 5 4 3 5 5 5
5 5 5 Reconsrcion levels Digial image processing Eamples of conras qanizaion: For he log ransform: 5 4.5 4 3.5 3.5.5.5 5 5 5 The ransfer fncion of he conras qanizer...3.4.5.6.7.8.9 = =46.73 3=.733 4=7.68 5=55 Decision levels 9 8 7 6 5 4 3
Digial image processing b. Psedorandom noise qanizaion diher mn vmn K bis v mn + qanizer + + mn - mn Uniforml disribed psedorandom noise [-AA] Large diher amplide Uniform qanizaion B=4 Prior o diher sbracion Small diher amplide
Digial image processing a b c d Fig. 3 a. 3 bis qanizer =>visible false conors; b. 8 bis image wih psedo-random noise added in he range [-66]; c. he image from Figre b qanized wih a 3 bis qanizer d. he resl of sbracing he psedo-random noise from he image in Figre c
Digial image processing Halfone images generaion H Lminance mna + + + vmn mna Thresholding v Psedorandom mari Fig.4 Digial generaion of halfone images 4 6 5 9 8 7 4 4 5 3 9 3 8 7 6 5 3 Demo: hp://marschlze.ne/halfone/inde.hml H A v mn Halfone displa 5 44 36 4 3 4 48 56 6 4 8 6 8 36 64 68 8 5 44 7 76 84 9 4 96 88 8 3 4 48 56 5 44 36 4 8 36 64 6 4 8 6 5 44 7 68 8 4 96 88 8 76 84 9 Fig.5 Halfone marices
Digial image processing Fig.3.6
Digial image processing Color images qanizaion R N T T R N Qanizer G N Color space ransformaion T T Qanizer Color space inverse ransformaion G N B N T 3 Qanizer T 3 B N Fig.7 Color images qanizaion