morphingcslee/ip(under)/8%c0%e5.pdf1 1 8장이미지워핑과모핑 2 개요...
TRANSCRIPT
1
1
8장 이미지 워핑과 모핑
2
개요이미지워핑(warping) : 특정규칙에의한영상의재추출(resampling)ò stretch an image in several different directionsò originally used by NASA to straighten images returned by satellitesò rubber sheet analogy, 영상을늘이거나크기를조절하는기하학적처리, 순수한스케일링과달리크기 변화의 정도가 영상전체에대해 균일하지않다.모핑 : 다른영상과의결합 (metamorphosis)ò Warping and Cross-dissolving two images àwarp & blend
ú 크로스-디졸브ò 영상들이 순차적으로자연스럽게 융합 되도록 하는영상처리
ò Morphology(형태학)ú 영상내의 객체들의 구조를 수정하기 위한 연산들로 구성
ò 예) 최대값, 최소값필터링 , opening, closing etc.ò 2차원모핑
ú 전이모핑 : A Ò B ú 왜곡모핑 : A Ò A’
ò 응용분야ú 영화, 비디오게임, TV 프로그램, 뮤직비디오등
3
Morphing
ò transition morphú gradually transform source image to target
ú the final image look nothing like the original
ò distortion morphú gradually transform source image by stretching
or squeezing itself
ú resulting image looks similar to the original
4
5 6
2
7 8
공간변환(spatial transformations)
워핑 기법: 메쉬(mesh)의 기하학적 변형
ò 두 영상을 여러 메쉬(mesh)들로 나누고 그 메쉬를 순차적으로 입
력 영상에서 출력 영상으로정합 (corresponding grid)
ò 두 영상간의 부드러운 변형은 많은 중간영상들을요구
ò 중간 프레임들은 입력 메쉬와 출력 메쉬사이에서선형적으로 보
간(linear interpolation)
일반적인 세 가지의 변형 방법 (u,v) à(x, y)
ò Affine Transformation(어파인 변형)
ò Perspective Transformation(원근 변형, 투영 변형, 투시 변형)
ò Bilinear Transformation(양선형 변형)
ò 위의 세 가지 변환은 입력과 출력 좌표의 정규화가 요구됨
ò 모든 좌표 값들은 0.0과 1.0 사이의 값으로 정규화
9
Corresponding grids(meshes)
10
Warping sequence
(10,10) (25,16)
intermediate frames
11
Affine Transformation스케일, 회전, 이동또는이들의조합평행선들을보존하고, 선을따라등간격의점들이보존됨삼각형그리드의경우세개의점에의해기하학적으로 mapping삼각형à삼각형, 사각형à평행사변형사각형을일반사변형으로워핑하기위해서는양선형(bilinear) 또는원근(perspective) 변형이필요
제어점 2제어점 3(원영상) (변형 후영상)
제어점 1
Affine TransformationAffine Transformation
q Affine Transformation (scale, rotation, translation)
q Examples
+
=
fe
yx
dcba
yx
f
+
=
00
00
yx
ss
yx
f
+
=
00
001
yx
tyx
f
+
=
00
101
yxu
yx
f
+
−=
00
cossinsincos
yx
yx
fθθθθ
3
13
Affine Forward Mapping Function (Affine Forward 정합 함수)x = a11u + a21v + a31y = a12u + a22v + a32
u0, v0
u2, v2
u1, v1
x0, y0
x2, y2
x1, y1
x0, y0,x1,y1,x2,y2 : 출력 삼각형의 좌표u0, v0, u1, v1, u2, v2 : 입력 삼각형의 좌표
matrix
14
계수의 계산
ò Affine을 수행하는 계수들을 결정하기 위하여 매트릭스 UV의 역행렬을 양변에승산
−
−−
−
−−
−−−
=
111
det1
100
2
1
0
2
1
0
0112
01
10
2002
20
02
1221
12
21
32
22
12
31
21
11
yyy
xxx
vuvuuuvv
vuvuuuvv
vuvuuuvv
UVaaa
aaa
detUV = u0(v1-v2)-v0(u1-u2)+(u1v2 – u2v1) Reverse Mapping정방향의 정합을 계산할 경우 Hole이 발생할 수 있다. 다음 식을 이용하여 역방향의 정합을 구함.
[ ] [ ]
−−−−
−
−=
122132113211123122313221
1121
1221
12212211
00
111aaaaaaaaaaaa
aaaa
aaaayxvu
15 16
Perspective Transformation
원근변형:모든 각도에서의 선들을 유지 (projective 변형이라고도 함)
Affine 변형을 포함(즉, Affine 변형은 Perspective 변형의 부분집합)
원근 변형은 한 사변형을 다른 사변형으로 직접 정합시킬 수 없음.
ò 사변형A à정사각형à사변형B
정방향 정합 함수식(forward mapping)
u0, v0
u2, v2
u1, v1
x2, y2x3, y3u3, v3
332313
322212
332313
312111 ,avauaavauay
avauaavauax
++++
=++++
= 9개의 계수
17
ò preserve lines of all orientations
ò square-to-quadrilateral mappingò establish 4-point correspondences from (u,v) plane
onto (x,y) plane
(0,0) --> (x0,y0), (1,0) --> (x1,y1)
(0,1) --> (x2,y2), (1,1) --> (x3,y3)
ò get 9 coefficients, a11 through a33
ò apply equations, forward and reverse mapping
ò quadrilateral-to-square mappingò compute square-to-quadrilateral mapping coefficients
ò apply reverse equation of square-to-quadrilateral mapping
18
32103232211
32103232211
,,,,
yyyyyyyyyyyxxxxxxxxxxx
−+−=∆−=∆−=∆−+−=∆−=∆−=∆
3x∆ 3y∆=0 이고 =0 이면 평행사변형. 함수는 Affine 변형, 그 계수는다음 식에 의해 계산
100
,
332313
03212220112
03112210111
===
=−=−==−=−=
aaayayyayyaxaxxaxxa
X=(x1-x0)u+(x2-x1)v+x0
Y=(y1-y0)u+(y2-y1)v+y0 à affine 정합함수
4
19
만일 정합이 Affine 변형이 아닌 경우, 계수들은 다음 식에 의해 계산됨
1)/()()/()(
,,,,
33
1221133123
1221232313
03232303221120112
03132303211120111
=∆∆−∆∆∆∆−∆∆=∆∆−∆∆∆∆−∆∆=
=+−=+−==+−=+−=
ayxyxyxyxaxyyxyxyxa
yayayyayayyaxaxaxxaxaxxa
2
3
3
3 1 2
IHyGxFEyDx
vIHyGxCByAx
u++++
=++++
= ,
211222112311211322132312
321131123113331133123213
312232213321312332233322
,,,,,,
aaaaCaaaaHaaaaGaaaaFaaaaEaaaaDaaaaCaaaaBaaaaA
−=−=−=
−=−=−=
−=−=−=
Reverse Mapping
20
21
quadrilateral-to quadrilateral mapping
two step processtwo step process
22
원근 변형의 예
23
Bilinear Transformation수평 또는수직선을따라등간격의 점을보존하지만, 대각선(곡선으로 매핑)은 보존되지
못함.
원리 : 양선형보간법과같은원리로동작
양선형 보간법
)()()(
013201
32332
01001
uuyuuuuxuuuuxuu
−+=−+=−+=
)()()(
031203
12112
03003
vvxvvvvyvvvvyvv
−+=−+=
−+=
[ ] [ ]
=
4241
3331
2221
1211
1
aaaaaaaa
vuuvyx
* 정방향의 함수(Forward Mapping)
24
−
−−−
=
yxyxyxyx
aaaaaaaa
33
11
22
00
4241
3231
2221
1211
0011000101011111
324142313132
32212231124142111112
12212211
3111
41212
24
aaaayaxaCaaaaaaaayaxaB
aaaaAwhere
auaauaxv
AACBBu
−+−=
−+−+−=−=
+−−
=−±−
=Reverse mapping
계수의 결정
5
25
Bilinear Warping
f(u,v) è g(x,y), 8개의 mesh point 이용
u=a1x+a2y+a3xy+a4
v=a5x+a6y+a7xy+a8
(x,y)=(0,0) è(u,v) 결정èu,v정수이면g(0,0)=f(0,0)è u,v정수아니면
h(u,v)=au+bv+cuv+d 와 4개의 이웃값으로a,b,c,d결정èg(0,0)=f(u,v)
이후 이 과정을 모든 출력화소에 적용
26
Inverse Mapping
27 28
양선형 변형의 예
※수평 또는 수직선을 따라 등간격의 점을 보존하지만, 대각선은 보존하지 못함
29
Meshwarp 알고리즘
두 단계의 알고리즘
ò 첫 번째 : 영상의 행을 따라 처리
ò 두 번째 : 영상의 열을 따라 처리
입력 영상과 출력영상이 서로 대응되는 Mesh 또는 제어점 배열
을 가진다.
보간법 : 선형 보간법, 스플라인 등 다양한 보간법 이용
ò 입력 배열과 출력 배열간의보간법에 의해 새로운제어점 배열을
만든다.
30
meshwarp algorithmò 2 pass algorithm; process each row in one pass and
each column in second passò input to algorithm
ò source image and destination images, Is and Id (Hin x Win), with corresponding meshes or control points, S and D (h x w)
ò at each passú generate intermediate array of control points, Iú interpolate data points between control points resulting in
Ts and Ti with Hin x w or h x Winú resample each row or column to get Hin x Win
6
31
ò first pass ò map each input pixel into its proper output column
ú phase Iò fit vertical splines through x coordinates of each column of
control pointsò sample vertical splines as they cross each row, creating Ts and Ti
of Hin x wò compute scaling factor for resampling each rowú take x coordinates of source mesh as independent variable and
that of intermediate mesh as dependent variablesú interpolate new values for each pixel in a row and use the
new values to determine scaling factors
32
ú phase IIò resample each row of source with Fant’s algorithm, resulting in
intermediate image
ò second pass ò operate similar steps as of phase I onto columnsò resample each column of intermediate image, resulting in final
image
33 34
Distortion warping by meshwarp
35
Fant의재추출(resampling) 알고리즘
reduce aliasing artifacts by evaluating values of all input pixels when creating a output pixelcheck one of 3 conditions when treating each input pixelò input pixel is completely consumed without
generating a new output pixelò input pixel is completely consumed and a new
output pixel is generatedò output pixel is generated without entirely
consuming input pixel36
7
37
Downsampling
38
39
Upsampling
FF SCALE can be a variableSCALE can be a variable
40
41
범위 기반(Field-based) 워핑 알고리즘
“Feature-Based Image Metamorphosis”, 1992 SIGGRAPH
proceeding
ò 마이클 잭슨의 “Black or white” 뮤직비디오에 사용ò Mesh를 사용하지 않고 제어선을 사용
방법
ò 각 화소에 대해 제어선에 대한 수직거리계산
ò 수직교차가 있는 선상의 비율적인 위치 계산
ò 가중치 (여러 제어선일 경우)
bp
거리a제어선의길이
가중치
+
=)(
42
보간법 (2가지방법) ò 시작선과목적선의끝점들사이를보간
ò 각선의중앙위치, 각도, 길이를보간장점
ò 제어선에따른워핑대각선상의특징을조절가능하다. 단점
ò 속도가느리다
8
43
field-based warpingú draw control lines on source and corresponding
ones on target image
ú map pixels of source onto target depending on their positions to control lines
44
45 46
47
Cross-dissolve
Cross-dissolve
ò 모핑 처리의 완성 단계ú 워핑하는 각 프레임에 대해수행
ú 마지막 프레임의 대응되는 화소를 가중치 평균
ú 가중치
;*2_*1...
;20.11;__/__2
finalweightimagewarpedweightoutput
weightwieghtframesofnumnumframecurrentweight
+=
−==
48
9
49
Practical considerations when morphing
서로다른두영상에대한모핑은매우어렵다. ò 예를들면, 미러링등의선행작업으로입력영상과목표영상이같은방향을가리키도록한다.
ò 영상의크기를조절한다. ò 영상의배경을제거하거나같도록만든다. 많은제어점
ò 모핑을보다부드럽게만들어준다.