概述
Pérez, Patrick, Gangnet M , Blake A . Poisson image editing[J]. ACM Transactions on Graphics, 2003, 22(3):313.
上一篇:泊松融合笔记
-
待求解的问题
Δ f = ∇ ⋅ v ( x , y ) = d i v ( v ( x , y ) ) , ∀ ( x , y ) ∈ Ω , w i t h f ∣ R ∖ Ω = f ∗ ∣ R ∖ Ω Delta f=nablacdot v(x,y)=div(v(x,y)),forall (x,y)inOmega,withquad f|_{mathscr{R}setminusOmega}=f^*|_{mathscr{R}setminusOmega} Δf=∇⋅v(x,y)=div(v(x,y)),∀(x,y)∈Ω,withf∣R∖Ω=f∗∣R∖Ω
其中 R ⊂ R 2 mathscr{R}subset R^2 R⊂R2 表示背景图像区域, v ( x , y ) = ( ∂ I ( x , y ) ∂ x , ∂ I ( x , y ) ∂ y ) v(x,y)=(frac{partial I(x,y)}{partial x},frac{partial I(x,y)}{partial y}) v(x,y)=(∂x∂I(x,y),∂y∂I(x,y))是前景图片合并前的梯度, f : R 2 → R f:R^2rightarrow R f:R2→R,表示合并后在 Ω Omega Ω区域的灰度值函数,在目标区域的梯度要尽量接近合并前前景图片的梯度, f ∗ f^* f∗表示合并后在 Ω Omega Ω区域之外的灰度值函数,在边界处灰度连续,即 f ∣ R ∖ Ω = f ∗ ∣ R ∖ Ω f|_{mathscr{R}setminusOmega}=f^*|_{mathscr{R}setminusOmega} f∣R∖Ω=f∗∣R∖Ω。 -
扩大求解区域
为了使用FFT求解,需要将求解区域扩大到整个背景图像区域。扩充后问题的形式如下:
Δ f ( x , y ) = ∇ ⋅ V ( x , y ) = d i v ( V ( x , y ) ) , ∀ ( x , y ) ∈ R   a n d ∇ f ( x , y ) ⋅ n ⃗ ∣ ∂ R = 0 Delta f(x,y)=nablacdot V(x,y)=div(V(x,y)),forall (x,y)inmathscr{R},andquad nabla f(x,y) cdot vec n|_{partialmathscr{R}}=0 Δf(x,y)=∇⋅V(x,y)=div(V(x,y)),∀(x,y)∈Rand∇f(x,y)⋅n∣∂R=0
其中 V ( x , y ) V(x,y) V(x,y)定义为:
V ( x , y ) = { v ( x , y ) i f ( x , y ) ∈ Ω ∇ I ( x , y ) o t h e r w i s e V(x,y) = begin{cases} v(x,y)& ifquad (x,y)in Omega \ nabla I(x,y) &otherwise end{cases} V(x,y)={v(x,y)∇I(x,y)if(x,y)∈Ωotherwise
∇ f ( x , y ) ⋅ n ⃗ ∣ ∂ R = 0 nabla f(x,y) cdot vec n|_{partialmathscr{R}}=0 ∇f(x,y)⋅n∣∂R=0是黎曼边界条件, n ⃗ vec n n为图像边界的外法向,等价于:
( ∂ f ( x , y ) ∂ x , ∂ f ( x , y ) ∂ y ) ⋅ ( 1 , 0 ) = 0 , i f x = 0 ∣ ∣ x = W − 1 ( ∂ f ( x , y ) ∂ x , ∂ f ( x , y ) ∂ y ) ⋅ ( 0 , 1 ) = 0 , i f y = 0 ∣ ∣ y = H − 1 (frac{partial f(x,y)}{partial x},frac{partial f(x,y)}{partial y}) cdot (1,0)=0 ,if quad x=0||x=W-1 \ (frac{partial f(x,y)}{partial x},frac{partial f(x,y)}{partial y}) cdot (0,1)=0 ,if quad y=0||y=H-1 (∂x∂f(x,y),∂y∂f(x,y))⋅(1,0)=0,ifx=0∣∣x=W−1(∂x∂f(x,y),∂y∂f(x,y))⋅(0,1)=0,ify=0∣∣y=H−1
上述条件可转换为:
V x = ∂ I ( x , y ) ∂ x = 0 , i f x = 0 ∣ ∣ x = W − 1 V y = ∂ I ( x , y ) ∂ y = 0 , i f y = 0 ∣ ∣ y = H − 1 V^x=frac{partial I(x,y)}{partial x}=0 ,if quad x=0||x=W-1 \ V^y=frac{partial I(x,y)}{partial y}=0 ,if quad y=0||y=H-1 Vx=∂x∂I(x,y)=0,ifx=0∣∣x=W−1Vy=∂y∂I(x,y)=0,ify=0∣∣y=H−1 -
傅里叶变换
f ( x , y ) = 1 W H ∑ u = 0 W − 1 ∑ v = 0 H − 1 f ( u , v ) e − 2 π i ( x u W + y v H ) ∂ f ( x , y ) ∂ x = ( 2 π i W u ) f ( u , v ) , ∂ f ( u , v ) ∂ y = ( 2 π i H v ) f ( u , v ) ∂ 2 f ( x , y ) ∂ x 2 = ( 2 π i W u ) 2 f ( u , v ) , ∂ 2 f ( x , y ) ∂ y 2 = ( 2 π i H v ) 2 f ( u , v ) f(x,y)=frac{1}{WH}sum_{u=0}^{W-1}sum_{v=0}^{H-1}f(u,v)e^{-2pi i(frac{xu}{W}+frac{yv}{H})} \ frac{partial f(x,y)}{partial x}=(frac{2pi i}{W}u)f(u,v),frac{partial f(u,v)}{partial y}=(frac{2pi i}{H}v)f(u,v) \ frac{partial^2 f(x,y)}{partial x^2}=(frac{2pi i}{W}u)^2f(u,v), frac{partial^2 f(x,y)}{partial y^2}=(frac{2pi i}{H}v)^2f(u,v) f(x,y)=WH1u=0∑W−1v=0∑H−1f(u,v)e−2πi(Wxu+Hyv)∂x∂f(x,y)=(W2πiu)f(u,v),∂y∂f(u,v)=(H2πiv)f(u,v)∂x2∂2f(x,y)=(W2πiu)2f(u,v),∂y2∂2f(x,y)=(H2πiv)2f(u,v)
上述计算公式对 V ( x , y ) V(x,y) V(x,y)的分量分别计算也成立。
待求解的问题为:
∂ 2 f ( x , y ) ∂ x 2 + ∂ 2 f ( x , y ) ∂ y 2 = ∂ V x ( x , y ) ∂ x + ∂ V y ( x , y ) ∂ y , ( x , y ) ∉ ∂ R ⇔ ( ( 2 π i W u ) 2 + ( 2 π i H v ) 2 ) f ( u , v ) = ( 2 π i W u ) V x ( u , v ) + ( 2 π i W v ) V y ( u , v ) ( u = 1 , 2 , ⋯   , W − 2 , v = 1 , 2 , ⋯   , H − 2 ) frac{partial^2 f(x,y)}{partial x^2}+frac{partial^2 f(x,y)}{partial y^2}=frac{partial V^x(x,y)}{partial x}+frac{partial V^y(x,y)}{partial y},(x,y)notin {partial mathscr{R}} \ Leftrightarrow \ ((frac{2pi i}{W}u)^2+(frac{2pi i}{H}v)^2)f(u,v)=(frac{2pi i}{W}u)V^x(u,v)+(frac{2pi i}{W}v)V^y(u,v) \ (u=1,2,cdots,W-2,v=1,2,cdots,H-2) ∂x2∂2f(x,y)+∂y2∂2f(x,y)=∂x∂Vx(x,y)+∂y∂Vy(x,y),(x,y)∈/∂R⇔((W2πiu)2+(H2πiv)2)f(u,v)=(W2πiu)Vx(u,v)+(W2πiv)Vy(u,v)(u=1,2,⋯,W−2,v=1,2,⋯,H−2)
化简为:
f ( u , v ) = { ( 2 π i W u ) V x ( u , v ) + ( 2 π i W v ) V y ( u , v ) ( 2 π i W u ) 2 + ( 2 π i H v ) 2 u = 1 , 2 , ⋯   , W − 2 , v = 1 , 2 , ⋯   , H − 2 m e a n ( f ( u , v ) ) o t h e r w i s e f(u,v) = begin{cases} frac{(frac{2pi i}{W}u)V^x(u,v)+(frac{2pi i}{W}v)V^y(u,v)}{ (frac{2pi i}{W}u)^2+(frac{2pi i}{H}v)^2}& u=1,2,cdots,W-2,v=1,2,cdots,H-2 \ mean(f(u,v)) &otherwise end{cases} f(u,v)={(W2πiu)2+(H2πiv)2(W2πiu)Vx(u,v)+(W2πiv)Vy(u,v)mean(f(u,v))u=1,2,⋯,W−2,v=1,2,⋯,H−2otherwise
求得每一点得 f ( u , v ) f(u,v) f(u,v)再用傅里叶逆变换得到 f ( x , y ) f(x,y) f(x,y)。
最后
以上就是踏实春天为你收集整理的FFT解泊松方程的全部内容,希望文章能够帮你解决FFT解泊松方程所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复