Img Procssing - Lsson 4 Gomtric Oprtions nd Morphing Gomtric Trnsformtion Oprtions dpnd on Pil s Coordints. Contt fr. Indpndnt of pil vlus. f f (, ) (, ) ( f (, ), f ( ) ) I(, ) I', (,) (, ) I(,) I (, ) 2 Empl: Trnsltion f f (, ) 3 (, ) ( 3, ) I (, ) I ' Forwrd v.s. Invrs Mpping Forwrd mpping: Sourc f f (, ) (, ) Trgt Forwrd Mpping Two prolms with forwrd mpping: Hols nd ovrlps. (,) I(,) I (, ) (, ) Solution: Invrs mpping: f, Sourc f ( ) (, ) Trgt Invrs Mpping 3 4 IDC-CG
Empl: scling long Forwrd mpping: 2 Sourc Trgt Intrpoltions Wht hppns whn mpping function clcults frctionl pil ddrss? (,) (,) Invrs mpping: / 2 Intrpoltion: gnrts nw pil nlzing th surrounding pils. Sourc Trgt 5 6 Nrst Nighor Intrpoltion Th ssign vlu is tkn from th pil closst to th gnrtd ddrss. Advntg: Fst. Disdvntg: Jggd rsults. Discontinus rsults. Originl Img I (, ) I( round{ f (, )}, round{ f (, )}) Nrst N. Intrpoltion 7 8 IDC-CG 2
Originl Img Bilinr Intrpoltion Nrst N. Intrpoltion Th ssignd vlu is n intrmdit vlu twn th four nrst pils. 9 v v w Linr Intrpoltion v Bilinr Intrpoltion Th ssign vlu is wightd sum of th four nrst pils. Ech wight is proportionl to th distnc from ch isting pil. w w w v v v v Isolting v in th ov qution: w w NW V N NE whr w dfin ( α ) w v αv v α w w S SW SE S SW N NW V S 2 SE ( ) NE ( ) N IDC-CG 3
Nrst N. Intrpoltion Nrst N. Intrpoltion Bilinr Intrpoltion 3 4 ilinr Intrpoltion Tp of 2DTrnsformtions Trnsltion Scling Rottion Shr Affin Projctiv 5 6 IDC-CG 4
Trnsltion Scl Scl (,): (,) (,) Trnslt (,): (,) (,) Scl (2,3) Trnslt(2,4) Scl (2,3) 7 8 How cn w scl n ojct without moving its origin (lowr lft cornr)? Rflction Trnslt(-,-) Scl(-,) Trnslt(,) Scl(2,3) Scl(,-) 9 2 IDC-CG 5
Rottion Rott(): cos() sin() - sin() cos() How cn w rott n ojct without moving its origin (lowr lft cornr)? Trnslt(-,-) Rott(9) Trnslt(,) Rott(9) Rott(9) 2 22 Shr Shr (,): (,) (,) Shr(,) Shr(,2) Composition of Trnsformtions Rigid trnsformtion: Trnsltion Rottion (distnc prsrving). Similrit trnsformtion: Trnsltion Rottion uniform Scl (ngl prsrving). Affin trnsformtion: Trnsltion Rottion Scl Shr (prlllism prsrving). Projctiv trnsformtion Will lortd ltr (cross-rtio prsrving) All ov trnsformtions r groups whr Rigid Similrit Affin Projctiv. 23 24 IDC-CG 6
IDC-CG 7 25 Rigid Affin Similrit 26 Mtri Nottion Lt s trt th loction (,) s 3 vctor in homognous spc: t t t W Y W X W Y W X W Y X 27 Scl Scl(,): (,) (,) If or r ngtiv, w gt rflction. Invrs: S - (,)S(/,/) 28 Shr, Rottion Shr(,): (,) (,) Rott(): (,) (cossin, -sin cos) Invrs: R - ()R T ()R(-) cos sin sin cos cos sin sin cos
IDC-CG 8 29 Trnsltion Trnsltion(,): Invrs: 3 Affin Rprsnts gnrl linr trnsformtion in 2D Euclidn spc. Invrs ffin: Altrntivl: f d c f d c ' ' f d c 3 Projctiv Rprsnts gnrl linr trnsformtion in 2D homognous spc. Prsrvs lins. Prsrvs cross-rtio d 3 d 24 /d 4 d 23 Dos not prsrv prlllism. Cn simult prspctiv projction of plnr scn. h g f d c ; h g f d c h g 32 Trnsformtion Estimtion Lt: f (,,, 2, 3 ) ; f (,,, 2, 3 ) If th mppings r linr in { i } { i } th prmtrs cn stimtd using linr rgrssion.
Empl: Affin Trnsformtion c d f Altrntiv rprsnttion c d f Givn k points (P,P 2,..P k ) in 2D tht hv n trnsformd to (P',P' 2,..,P' k ) th ffin trnsformtion: How mn points uniqul dfin th trnsformtion? How cn w find th trnsformtion? Wht cn don if points coordints r in inccurt? H ˆ ˆ min T T ( H H ) H H 33 34 Img Trnsformtion using Mtl T [ ; c d]; % trnsformtion mtri [r,c] siz(img) Img Wrping nd Morphing Img rctifiction. % crt rr of dstintion, coordints [X,Y]mshgrid(:c,:r); % clcult sourc coordints sourccoor inv(t) * [X(:) Y(:) ] ; % clcult nrst nighor intrpoltion Xs round(sourccoor(,:)); Ys round(sourccoor(2,:)); indfind(xs< Xs>r); Xs(ind); Ys(ind); indfind(ys< Ys>c); Xs(ind); Ys(ind); % clcult nw img nwimg img((xs-).*rys); nwimg(ind); nwimg(ind); nwimg rshp(nwimg,r,c); K frm nimtion. Img Snthsis Fcil prssion. Viwing positions Img Mtmorphosis. Dmo 35 36 IDC-CG 9
Cross-Dissolv (Pil Oprtion) Sourc Img Dstintion Img From: http://www.cs.utk.du/~hungj/cs594f/imgmorph.ppt Dmo 37 38 Ftur Bsd Morphing Morph on shp into nothr shp. Comins pil oprtions nd gomtricl oprtions. Ftur Slction Morph 39 4 IDC-CG
Ftur morphing Algorithm: Dfin st of corrsponding fturs in ch img. Dfin n intrmdit configurtion for ch tim stp linrl intrpolting fturs. Wrp sourc img towrds intrmdit img. Wrp dstintion img towrds intrmdit img. Cross-disssolv th two imgs tking th wightd vrg t ch pil. Originl Sourc Img Wrpd Sourc Img sourc tim Cross-dissolv Cross-dissolv of th Originl imgs Cross-dissolv of th Wrpd Imgs dstintion Intrmdit imgs 4 Originl Dst. Img 42 Wrpd Dst Img wrp Ftur sd Wrping Q Cross-dissolv P Cross-dissolv wrp P 43 44 IDC-CG
Q Q P P P P 45 46 Q Q P P P P 47 48 IDC-CG 2
Q On Lin wrping P Q β R α u v P Sourc Img β R α u v P Dst Img α is th rltiv position long th lin. P 49 α gos from to s R movs from P to. β is th ctul prpndiculr distnc to th lin. Th position of R is mppd into (α,β): R ( α β ) whr R' P' α Q' P' uˆ' βvˆ ' Invrs mpping: R( α, β ) P α Q P uˆ βvˆ u is unit vctor prlll to Q-P v is th unit vctor in th dirction prpndiculr to Q-P 5 Clculting u, v : Multipl Lin Wrping With Multipl lin wrping th point is influncd ch lin. Clcult unit vctors u, v : ( Q P ) û û Q P vˆ û û Clcult α, β : u v α β β ( R P ) û Q P ( P ) vˆ R 5 R α P Q R β R 2 P Q 2 β 2 P 2 Th influnc of ch lin is: p Qi P i W i β i Th vlu p [,] dictts th influnc of th lin lngth. Th vlu is smll numr voiding division zro. Th vlu dtrmins how th rltiv wight diminish s th β incrss WkRk Th finl mpping is: k R Wk 52 Q R β β 2 u 2 P P 2 k Q 2 IDC-CG 3
Msh Wrping Empl imgs from: http://www.cc.gtch.du/clsss/ay2/cs445_spring/projcts/svn/ For mor dtils s: Thddus Bir / Ftur-Bsd Img Mtmorphosis Siggrph '92 http://www.hmmrhd.com/thd/morph.html 53 From: http://www.cs.utk.du/~hungj/cs594f/imgmorph.ppt Dmo 54 IDC-CG 4