我是靠谱客的博主 踏实春天,最近开发中收集的这篇文章主要介绍FFT解泊松方程,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Pérez, Patrick, Gangnet M , Blake A . Poisson image editing[J]. ACM Transactions on Graphics, 2003, 22(3):313.

上一篇:泊松融合笔记

  1. 待求解的问题
    Δ 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)Ω,withfRΩ=fRΩ
    其中 R ⊂ R 2 mathscr{R}subset R^2 RR2 表示背景图像区域, 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)=(xI(x,y),yI(x,y))是前景图片合并前的梯度, f : R 2 → R f:R^2rightarrow R f:R2R,表示合并后在 Ω Omega Ω区域的灰度值函数,在目标区域的梯度要尽量接近合并前前景图片的梯度, f ∗ f^* f表示合并后在 Ω Omega Ω区域之外的灰度值函数,在边界处灰度连续,即 f ∣ R ∖ Ω = f ∗ ∣ R ∖ Ω f|_{mathscr{R}setminusOmega}=f^*|_{mathscr{R}setminusOmega} fRΩ=fRΩ

  2. 扩大求解区域
    为了使用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)Randf(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 (xf(x,y),yf(x,y))(1,0)=0,ifx=0x=W1(xf(x,y),yf(x,y))(0,1)=0,ify=0y=H1
    上述条件可转换为:
    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=xI(x,y)=0,ifx=0x=W1Vy=yI(x,y)=0,ify=0y=H1

  3. 傅里叶变换
    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=0W1v=0H1f(u,v)e2πi(Wxu+Hyv)xf(x,y)=(W2πiu)f(u,v),yf(u,v)=(H2πiv)f(u,v)x22f(x,y)=(W2πiu)2f(u,v),y22f(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) x22f(x,y)+y22f(x,y)=xVx(x,y)+yVy(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,,W2,v=1,2,,H2)
    化简为:
    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,,W2,v=1,2,,H2otherwise
    求得每一点得 f ( u , v ) f(u,v) f(u,v)再用傅里叶逆变换得到 f ( x , y ) f(x,y) f(x,y)

最后

以上就是踏实春天为你收集整理的FFT解泊松方程的全部内容,希望文章能够帮你解决FFT解泊松方程所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部