In this project, I implemented the paper "Image deformation using moving least square" which is proposed by Scott Schaefer. This method consists of three type of deformation:affine deformation,similarity deformation and rigid deformation. And it also use both controlling point sets and controlling line segment sets to specify the morph.
The MLS (Moving Least Squares) Deformation is used to find the best transformation function f that maps p to q . p is a set of controlled handles and q is the deformed positions of the controlled handles. The function f(v) needs to satisfy three conditions:(1) Interpolation: The handles p should map directly to q under deformation (i.e. f(pi)=qi )(2) Smoothness: f should produce smooth deformations (3)Identity: If the deformed handles q are the same as the p , then f should be the identity function.(i.e., qi=pi ⇒f(v)=v )
Affine transform: lv(x)=xM+T
Translation can be removed: T=q∗−p∗M
p∗=ΣiwipiΣiwi q∗=ΣiwiqiΣiwi
We can easily get: Iv(x)=(x−p∗)M+q∗
The new cost function:
Σiwi|p^iM−q^i|2 where p^i=pi−p∗ q^i=qi−q∗
M could be different class of transformations
Solution: M=(Σip^Tiwip^i)−1Σjwjp^Tjq^j
The deformation function:
fa(v)=ΣjAjq^j+q∗
Aj=(v−p∗)(Σip^Tiwip^i)−1p^Ti
Aj can be precomputed
Contains non-uniform scaling and shear
A special subset of affine transformations
Translation,Rotation,Constraints: Uniform-Scaling
Requirements: MTM=λ2I
Define M=(M1,M2) , where M2=M⊥1
Cost function (Least squares problem) still quadratic in M
Σiwi|(p^i−p^⊥i)M−q^Ti|2 , where (x,y)⊥=(−y,x)
Solution for matrix M
M=1μsΣiwi(p^i−p^⊥i)(q^Ti,−qi^⊥T) , where μs=Σiwip^ip^Ti
Solution for deformation function
fs(v)=Σiq^i(1μsAi)+q∗ ,where Ai=wi(p^i−p^⊥i)(v−p∗−(v−p∗)⊥)T
Solution for Matrix M
M=Σi(p^i−p^⊥i)(q^Ti,−qi^⊥T)(Σiwiq^ip^Ti)2+(Σiwiq^ip^⊥Ti)2√
Solution for deformation function
fr(v)=|v−p∗|f→r(v)|f→r(v)|+q∗ , where f→r(v)=Σiq^iAi and Ai is the same as in similarity deformations.
I do the similar experiment but with the opposite direction. The puppet leans towards right.
The author's results
My own results
Original Image | Affine Deformation | Similarity Deformation | Rigid Deformation |
Some interesting result
Monalisa | Deformed Monalisa |
Girrafe | Deformed Girrafe |
Generally speaking, the MLS image deformation using controlled points produces the result as I have expected. The rigid deformation can produce the most realistic result compared with other methods in my implementation but with the lowest speed.
Handles are control curves instead of control points
Cost function
Σi∫10wi(t)|pi(t)M+T−qi(t)|2 and wi(t)=|p′i(t)||pi(t)−v|2α
T still can be removed
T=q∗−p∗M
T=q∗−p∗M
Σi∫10wi(t)|p^i(t)M−q^i(t)|2
where p^i(t)=pi(t)−p∗ and q^i(t)=qi(t)−q∗
Represent line segments p^i(t) , q^i(t) as matrix products
p^i(t)=(1−t,t)(a^ib^i) and q^i(t)=(1−t,t)(c^id^i)
Cost function
Σi∫10|(1−t,t)((a^ib^i)M−(c^id^i))|2
Minimizer
M=(Σi(a^ib^i)TWi(a^ib^i))−1Σj(a^ib^i)TWj(c^id^i)
Wi=(δ00iδ01iδ01iδ11i) where δ00i=∫10wi(t)(1−t)2dt
δ01i=∫10wi(t)(1−t)tdt and δ11i=∫10wi(t)t2dt
Deformation
fa(v)=ΣjAj(c^id^i)+q∗
Aj=(v−p∗)(Σi(a^ib^i)TWi(a^ib^i))−1(a^jb^j)TWj
Cost function
Σi∫10|(1−t001−tt00t)⎛⎝⎜⎜⎜⎜⎜a^i−a^⊥ib^i−b^⊥i⎞⎠⎟⎟⎟⎟⎟M−(c^Tid^Ti)|2
Minimizer
M=1μsΣj⎛⎝⎜⎜⎜⎜⎜a^i−a^⊥ib^i−b^⊥i⎞⎠⎟⎟⎟⎟⎟TWj(c^Tjd^Tjc^⊥Tjd^⊥Tj)
where μs=Σia^ia^Tiδ00i+2a^