图像算法---Image Deformation Using Moving Least Squares

原文地址:http://vision.gel.ulaval.ca/~jflalonde/cours/4105/h14/tps/results/project/jingweicao/index.html

Final Project: Image Deformation Using Moving Least Squares

Jingwei Cao

Project Description

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.

Part1: Moving Least Squares Deformation

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 )

1 Affine Deformation

Affine transform:  lv(x)=xM+T
Translation can be removed:  T=qpM
p=ΣiwipiΣiwi   q=ΣiwiqiΣiwi
We can easily get:  Iv(x)=(xp)M+q
The new cost function:
Σiwi|p^iMq^i|2  where  p^i=pip   q^i=qiq
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=(vp)(Σip^Tiwip^i)1p^Ti
Aj can be precomputed
Contains non-uniform scaling and shear

2 Similarity Deformation

A special subset of affine transformations
Translation,Rotation,Constraints: Uniform-Scaling
Requirements:  MTM=λ2I
Define  M=(M1,M2) , where  M2=M1
Cost function (Least squares problem) still quadratic in  M
Σiwi|(p^ip^i)Mq^Ti|2 , where  (x,y)=(y,x)
Solution for matrix  M
M=1μsΣiwi(p^ip^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^ip^i)(vp(vp))T

3 Rigid Deformation

Solution for Matrix  M
M=Σi(p^ip^i)(q^Ti,qi^T)(Σiwiq^ip^Ti)2+(Σiwiq^ip^Ti)2
Solution for deformation function
fr(v)=|vp|fr(v)|fr(v)|+q , where  fr(v)=Σiq^iAi  and  Ai  is the same as in similarity deformations.

4 Experimental Results

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
图像算法---Image Deformation Using Moving Least Squares_第1张图片 图像算法---Image Deformation Using Moving Least Squares_第2张图片 图像算法---Image Deformation Using Moving Least Squares_第3张图片

Some interesting result

Monalisa Deformed Monalisa
图像算法---Image Deformation Using Moving Least Squares_第4张图片
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.

Part2: Deformation with Line Segments

Handles are control curves instead of control points
Cost function
Σi10wi(t)|pi(t)M+Tqi(t)|2  and  wi(t)=|pi(t)||pi(t)v|2α
T still can be removed
T=qpM
T=qpM
Σi10wi(t)|p^i(t)Mq^i(t)|2
where  p^i(t)=pi(t)p  and  q^i(t)=qi(t)q

1 Affine Lines

Represent line segments  p^i(t) , q^i(t)  as matrix products
p^i(t)=(1t,t)(a^ib^i)  and  q^i(t)=(1t,t)(c^id^i)
Cost function
Σi10|(1t,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)(1t)2dt
δ01i=10wi(t)(1t)tdt  and  δ11i=10wi(t)t2dt
Deformation
fa(v)=ΣjAj(c^id^i)+q
Aj=(vp)(Σi(a^ib^i)TWi(a^ib^i))1(a^jb^j)TWj

2 Similarity Lines

Cost function
Σi10|(1t001tt00t)a^ia^ib^ib^iM(c^Tid^Ti)|2
Minimizer
M=1μsΣja^ia^ib^ib^iTWj(c^Tjd^Tjc^Tjd^Tj)
where  μs=Σia^ia^Tiδ00i+2a^

你可能感兴趣的:(发型,最小二乘,图像变形,瘦脸)