<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://rainzor.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://rainzor.github.io/" rel="alternate" type="text/html" /><updated>2026-09-15T08:07:27+00:00</updated><id>https://rainzor.github.io/feed.xml</id><title type="html">Rainzor’s Home Page</title><subtitle>personal description</subtitle><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><entry><title type="html">Graphene Research</title><link href="https://rainzor.github.io/blogs/graphene" rel="alternate" type="text/html" title="Graphene Research" /><published>2023-06-10T00:00:00+00:00</published><updated>2023-06-10T00:00:00+00:00</updated><id>https://rainzor.github.io/blogs/graphene</id><content type="html" xml:base="https://rainzor.github.io/blogs/graphene"><![CDATA[<p>A research about the properties of graphene (<strong>中文/CN</strong>)</p>

<p>If you want to view the source codes, you can search for them in my <a href="https://github.com/Rainzor/GrapheneResearch">GitHub repository</a>.</p>

<h1 id="1-简介">1. 简介</h1>

<p>石墨烯是由碳原子构成的一种二维材料，具有许多独特的性质，包括出色的热学性质和电子性质。石墨烯的发现引起了全球科学界的高度关注，并且已经在许多领域中得到了广泛应用，例如电子元件、传感器、能源存储和转换等</p>

<p>作为碳的单原子平面，石墨烯可以包裹成其他石墨材料，如富勒烯、碳纳米管和石墨烯薄膜。由于内部具有极高的晶体质量和无质量狄拉克费米子，单层石墨烯表现出异常的半整数量子霍尔效应、卓越的光学性能、超高的本征强度、优异的导热性和极高的载流子迁移率。它被称为零间隙半导体，由于费米能级附近独特的狄拉克锥带结构，显示出异常高的电荷载流子浓度和弹道传输。此外，无质量电子在亚微米距离内无散射地通过蜂窝晶格的传播使得即使在室温下也可以研究石墨烯中的量子效应</p>

<h1 id="2-石墨烯结构">2. 石墨烯结构</h1>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/石墨烯结构分类.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 2.1. 石墨烯纳米带分类 （a）椅型边纳米带，（b）锯齿边纳米带，（c）螺旋边纳米带
    </div>
    <p> </p>
</center>
<h2 id="21-晶胞">2.1 晶胞</h2>

<p>理想的石墨烯是具有正六方晶格结构的单层二维原子晶体。 C-C键的长度约为0.142 nm，层厚为0.35 nm。在每个状态下，单个碳原子通过 $sp^2$ 轨道杂化分别与其三个最近的邻居形成强 σ 键，导致占据和未占据状态相互远离。石墨烯的每个晶胞都有A型和B型两种亚晶格</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/graphene.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 2.2. 石墨烯晶胞
    </div>
    <p> </p>
</center>

<p>设 $a_0=0.142 nm$,晶格常数为 $a=\sqrt3 a_0$,那么石墨烯的晶胞基矢可以写为</p>

\[\mathbf{a_1}= \frac{a}{2}(\sqrt 3,1)\\
\mathbf{a_2}= \frac{a}{2}(\sqrt 3,-1)\]

<p>那么晶格的倒格矢定义为</p>

\[\mathbf{b_1}=\frac{2\pi}{a}(\frac{1}{\sqrt 3},1)\\
\mathbf{b_2}=\frac{2\pi}{a}(\frac{1}{\sqrt 3},-1)\]

<p>倒格子空间中，格点之间的最小间距是： $b_0=\frac{4\pi}{3\sqrt3a_0}$</p>

<h4 id="最近邻矢量">最近邻矢量</h4>

\[\delta_1=\frac{a_0}{2}(1,\sqrt3)\\
\delta_2=\frac{a_0}{2}(1,-\sqrt3)\\
\delta_3=-a_0(1,0)\]

<h2 id="22-化学键">2.2 化学键</h2>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/化学键.png" width="80%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
    </div>
    <p> </p>
</center>

<p>碳是元素周期表中的第六元素，基态电子排布为$1s^ 2 2s^ 2 2p_ x ^ 1 2p_ y ^ 1 2p_z^  0$,当碳原子与其相邻的三个碳原子共享$sp^ 2$ 电子时，它们形成一层平面结构的蜂窝网络，也称为单层石墨烯。</p>

<p>在石墨烯层上两个相邻碳原子的典型 $sp^ 2$ 杂化中，面外 $\pi$ 键由垂直于平面结构的 $2p_ z$ 轨道组成，而面内σ键由$sp^ 2$ （$2s$，$2p_x$  和 $2p_y$ ）杂化轨道形成。</p>

<p>产生的共价 $\sigma$ 键具有约 $1.42\overset{\circ}{A}$ 的短原子间长度，使其甚至比金刚石中的 $sp^ 3$ 杂化碳-碳键更强，从而赋予单层石墨烯显着的机械性能（例如 $1 T Pa$ 的杨氏模量和固有抗拉强度为 $130.5 GPa$)。</p>

<p>在单层石墨烯中，π 键杂化在一起形成 π 带和 π * 带。这些带通过允许自由移动电子的半填充带负责石墨烯的大部分显着电子特性。由于允许电子自由移动的半满π带，形成了零带隙的导带和价带。此外，$\pi$ 键在双层和多层石墨烯中的相邻石墨烯层之间提供了弱的范德华相互作用。</p>

<h2 id="23-结合能">2.3 结合能</h2>

<p>​	在一定力程范围内，考虑到原子间短程相互作用，石墨烯的平均相互作用能为：</p>

\[\phi(d)=-V_2\left[1-\frac{9R}{V_2 d^ {12}}+5\beta_2\left(\frac{V_1}{V_2}\right)^2\right]\]

<p>式中 $V_2$ 为两原子的 $sp^2$ 轨道 $\sigma$ 键的共价能, 它与原子间距离 $d$的平方成反比:</p>

\[V_2=3.26\frac{\hbar}{m_ed^2}=\frac{B}{d^2}\]

<p>其中 $m_e$ 为电子质量。而$V_1$ 为金属化能, $V_1=(\epsilon_s-\epsilon_p)/4=2.08 eV$, $\epsilon_s$ 和 $\epsilon_p$ 分别是 $s$ 和 $p$ 态电子的能量；$R=10.08eV\times(10^{-10}m)^{12}$，$\beta_2$ 是与维数有关的参量, 对石墨烯 $\beta_2=2/3$</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/结合能.png" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 3.1. 结合能
    </div>
    <p> </p>
</center>

<p>求导可以得到稳定平衡点
\(d_0 =1.37354\times10^{-10}m\)
和实验值 $a_0=1.42\times 10^{-10}m$ 相比，比较接近</p>

<h1 id="3-晶格振动">3. 晶格振动</h1>

<h2 id="31-晶格动力学">3.1 晶格动力学</h2>

<h3 id="动力学矩阵">动力学矩阵</h3>

<p>根据晶格动力学，对于任意处于 $i$ 坐标处 $\mathbf u_i=(x_i,y_i,z_i)^T$,其对于含有N个原子的晶胞，受到的作用力可以写作</p>

\[M_i\frac{d^2u_i}{dt^2}=\sum_jK^{(i,j)}(u_j-u_i),\qquad(i=1,...,N)\]

<p>其中 $K^{(i,j)}$ 代表了 $i$ 和 $j$ 之间的  $3\times 3$ 的弹性张量矩阵。</p>

<p>对于上述微分方程，由于一个原胞中含有两个独立的格点 $A,B\in R^3$，所以设试探解为</p>

\[u^A=A\exp[i(\mathbf{k\cdot (r-r_{Ai})}-wt)]\\
u^B=B\exp[i(\mathbf{k\cdot (r-r_{Bi})}-wt)]\]

<p>代入(7) ，如果假设 $u _ i $ 是 $A$ 原子，且由于所有原子质量 $M_i$ 都一样，得到</p>

\[-Mw^2I\mathbf u_i^A=\sum_{j_A}K^{(i,j_A)}(\mathbf u_{j_A}^A-\mathbf u_i^A)+\sum_{j_B}K^{(i,j_B)}(\mathbf u_{j_B}^B-\mathbf u_i^A)\]

<p>其中 $j_A，j_B$ 分别代表了 $u_i$ 受到的作用力来自 A类原子和B类原子，继续代入，消去 $ u_i $</p>

\[-AMw^2I=\sum_{j_A}K^{(i,j_A)}\left(e^{-i\mathbf{k\cdot\Delta r_{ij_A}}}-1\right)A+\sum_{j_B}K^{(i,j_B)}\left(e^{-i\mathbf{k\cdot\Delta r_{ij_B}}}B-A\right)\]

<p>其中 $\Delta r_ {ij}$ 是两个原子的相对距离，整理一下得到，</p>

\[\left(\sum_jK^{(ij)}-\sum_{j_A}K^{(i,j_A)}e^{-i\mathbf{k\cdot\Delta r_{ij_A}}}\right)A-\sum_{j_B}K^{(i,j_B)}e^{-i\mathbf{k\cdot\Delta r_{ij_B}}}B=Mw^2A\]

<p>同理 $B$ 原子应该在方程形式上和 $A$ 原子等价，得到</p>

\[-\sum_{j_A}K^{(i,j_A)}e^{-i\mathbf{k\cdot\Delta r_{ij_A}}}A+\left(\sum_jK^{(ij)}-\sum_{j_B}K^{(i,j_B)}e^{-i\mathbf{k\cdot\Delta r_{ij_B}}}\right)B=Mw^2B\]

<p>注意 $A,B$ 是一个 $R^{3\times1}$ 的向量，得到一下特征方程</p>

\[\begin{bmatrix}
\left(\sum_jK^{(ij)}-\sum_{j_A}K^{(i,j_A)}e^{-i\mathbf{k\cdot\Delta r_{ij_A}}}\right)&amp; -\sum_{j_B}K^{(i,j_B)}e^{-i\mathbf{k\cdot\Delta r_{ij_B}}}\\
-\sum_{j_A}K^{(i,j_A)}e^{-i\mathbf{k\cdot\Delta r_{ij_A}}}&amp; \left(\sum_jK^{(ij)}-\sum_{j_B}K^{(i,j_B)}e^{-i\mathbf{k\cdot\Delta r_{ij_B}}}\right)
\end{bmatrix}
\begin{bmatrix}
A\\
\\
B
\end{bmatrix}
=Mw^2
\begin{bmatrix}
A\\
\\
B
\end{bmatrix}\]

<p>可以将上面的 $6\times6$ 动力学矩阵分块</p>

\[D=\begin{bmatrix}
D^{AA}&amp;D^{AB}\\
D^{BA}&amp;D^{BB}
\end{bmatrix}\]

<h3 id="近邻原子">近邻原子</h3>

<p>同时为了简化问题，只考虑到第4近邻的原子作用</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Neighbor.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.1. 近邻原子
    </div>
    <p> </p>
</center>

<h3 id="弹性张量">弹性张量</h3>

<p>A原子最邻近的原子有 $B_1,B_2,B_3$</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Force Tensor.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.2. 作用力
    </div>
    <p> </p>
</center>

<p>对于最邻近的原子 $A,B_1$ 之间的张量矩阵在特征空间下，可以写作</p>

\[K^{(A,B_1)}=\begin{bmatrix}
\phi_r^{(1)}&amp;0&amp;0\\
0&amp;\phi_{ti}^{(1)}&amp;0\\
0&amp;0&amp;\phi_{to}^{(1)}
\end{bmatrix}\]

<p>而其他的原子的张量矩阵可以通过旋转变换矩阵来实现</p>

\[K^{(A,B_m)}=U_mK^{(A,B_1)}U_m\quad (m=2,3)\]

<p>其中旋转矩阵 $U_m$ 为</p>

\[U_m=\begin{pmatrix}
\cos\theta_m&amp;\sin\theta_m&amp;0\\
-\sin\theta_m&amp;\cos\theta_m&amp;0\\
0&amp;0&amp;1
\end{pmatrix}\]

<p>对于考虑到第4临界的弹性张量矩阵，在特征空间下矩阵的值为</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Force Para.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.3. 弹性系数，其中的单位是10N/m
    </div>
    <p> </p>
</center>

<h2 id="32-色散关系">3.2 色散关系</h2>

<p>根据 <code class="language-plaintext highlighter-rouge">dispersion_3D.m</code> <code class="language-plaintext highlighter-rouge">dispersion_2D.m</code> 可以得到一下色散关系图</p>

<h4 id="三维">三维</h4>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Dispersion3D.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.4. 色散关系3D
    </div>
    <p> </p>
</center>

<h3 id="二维">二维</h3>

<p>当沿着 $\Gamma,M,K,\Gamma$ 方向画出平面色散关系</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/graphene2.jpg" width="30%" />
    <br />
</center>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Dispersion2D.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.5. 色散关系
    </div>
    <p> </p>
</center>

<h4 id="x-w投影平面">X-W投影平面</h4>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/project_x_w.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.6. X-W色散关系
    </div>
    <p> </p>
</center>

<p>从图像中可以看到一下一些结论</p>

<ol>
  <li>对于原胞中有2个原子的石墨烯材料，共有 $3\times2$支色散波段。其中3只为声学支，为 ZA,TA,LA；3只为光学波段，为ZO,LO,TO</li>
  <li>纵向 (L) 模式对应于沿波传播方向（压缩波）的原子位移，而横向 (T) 模式对应于垂直于传播方向（剪切波）的面内位移。在典型的三维 (3D) 固体中，横向模式可以具有两个等效极化，但石墨烯独特的二维性质允许面外原子位移，也称为弯曲 (Z) 声子。</li>
  <li>在低频区间，声学支占主导，且曲线变化比较陡峭，占据了大多数频率区间；而光学支只在高频处占主导，且占据范围较小</li>
  <li>在布里渊区中心附近的低 k 处，横向声学支 (TA) 和纵向声学支 (LA) 模式的频率具有线性色散,即 $w_{TA}\approx v_{TA}k$ ， $ω_{LA} \approx v_{LA}k$ ，由于石墨烯的在面内 $\sigma $ 键和小质量特性，其具有较大的群速度 $v_{TA}\approx 13.9 km/s$ ，$v_{LA}\approx 20.5 km/s$ (模拟拟合曲线)</li>
  <li>在布里渊区中心附近的低 k 处，弯曲 ZA 模式具有近似二次色散，$w_{ZA}\approx \alpha k^2$ , 其中 $\alpha = 5.7 \times 10^-7 m^2/s$(模拟曲线拟合) ，正是 ZA 模式的存在和修改是造成石墨烯许多不寻常的热特性的原因。比如高热导率：</li>
</ol>

<h2 id="33-杨氏模量">3.3 杨氏模量</h2>

<p>可以用经验公式导出杨氏模量</p>

\[E=\rho v_g^2\]

<p>其中 $\rho=2.2\times10^3 kg/m^3$ 为石墨烯密度； $v_g$ 为石墨烯声速。</p>

<p>如果把上面声学支的色散关系都认为是线性的，那么在这种程度近似下，声速是</p>

\[v_g^2=(v_{TA}^2+v_{LA}^2+v^2_{ZA})/3=4.923\times 10^8 (m/s)^2\]

<p>于是可以得到石墨烯的杨氏模量</p>

\[E=1.0832\times10^{12} Pa\]

<p>于实验值相比 $1.0\pm0.1 TPa$ 已经非常接近了</p>

<h2 id="34-态密度">3.4 态密度</h2>

<p>利用提供的代码 <code class="language-plaintext highlighter-rouge">DOS_frequency.m</code>， 对第一布里渊区内进行统计，可以得到如下频率态密度分布</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/DOS.png" width="60%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.7. 态密度分布
    </div>
    <p> </p>
</center>

<p>在频率较低处是声学支占主导，态密度近似为单调的线性函数形式，但是在 $1.5\times10^{14}$以及在大于$2.5\times 10^{14}$ 处光学支发挥作用，态密度激增。(文献中给出的态密度如下)</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/实际态密度.png" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.8. 实际态密度
    </div>
    <p> </p>                  
</center>

<h1 id="4-热容">4. 热容</h1>

<h2 id="41-dulong-petit-定律">4.1 Dulong-Petit 定律</h2>

<p>考虑经典能均分定理，得到其摩尔热容为</p>

\[C_V=3N_ak_B=24.943 J\cdot mol^{-1}\cdot K^{-1}\]

<h2 id="42--einstein-model">4.2  Einstein Model</h2>

<p>在与环境温度处于热平衡状态时谐振子按时间的平均能量为:</p>

\[\bar\varepsilon_i=\frac{\hbar\omega_i}{2}+\frac{\hbar\omega_i}{e^{\hbar\omega_i/k_BT}-1}\]

<p>Einstein Model 认为所有原子处于相同的频率，对于石墨烯中近似认为 $\omega_E=2\times10^{14} rad/s$，进而得到 $Einstein$ 温度 $T_E$</p>

\[T_E=\frac{\hbar\omega_E}{k_B}=1.53\times 10^3 K\]

<p>对于N个原胞的石墨烯系统，每个原胞中含有两个原子 $n=2$,得到热容为</p>

\[\begin{equation}
\begin{aligned}
C_V&amp;=3Nnk_B\frac{\partial}{\partial T}\left(\frac{\hbar\omega_E}{e^{\hbar\omega_i/k_BT}-1}\right)\\
&amp;=3Nnk_B\left(\frac{T_E}{ T}\right)^2\frac{e^{T_E/T}}{(e^{T_E/T}-1)^2}\\

&amp;=3Nnk_Bf_E(\frac{T_E}T)
\end{aligned}
\end{equation}\]

<p>在高温下： $f_E(T_E/T)\approx1$</p>

\[C_V\approx 3Nnk_B=3N_Ak_B\]

<p>在低温时：</p>

\[C_V=3Nnk_B\left(\frac{T_E}T\right)^2e^{-T_E/T}\]

<h2 id="43-debye-model">4.3 Debye Model</h2>

<p>Debye（1912）修正了原子是独立谐振子的概念，而考虑晶格的集体振动模式，他假设晶体是连续弹性介质，原子的热运动以弹性波的形式发生。弹性波频率上限 $\omega_D$，称之为德拜频率</p>

\[\omega=v_sq\\
\frac{3}{v_s^2}=\frac1{v_{TA}^2}+\frac1{v_{LA}^2}+\frac1{v^2_{ZA}}\]

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/project_x_w_bad.png" width="40%" />
    <br />
</center>

<p>对于弹性波，二维平面中色散关系是</p>

\[g(w)=\frac{S\omega}{2\pi}\left(\frac1{v_{TA}^2}+\frac1{v_{LA}^2}+\frac1{v^2_{ZA}}\right)=\frac{3S\omega}{2\pi v_s^2}\]

<p>其中 $S$ 是平面总面积，为 $\frac{3\sqrt3 a_0^2}{2}N$。</p>

<p>由于有N个原胞，每个原胞有2个原子，自由度为6，所以总振动模式有 $6N$个，所以有：</p>

\[\int_0^{\omega_D}g(w)dw=6N\\
\omega_D=\left(\frac{8\pi N}{S}\right)^{1/2}v_s\approx 1.6734\times10^{14} rad/s\]

<p>有此得到 $Debye$ 温度 $T_D=\frac{\hbar w_D}{k_B}\approx1273.24 K$</p>

<p>结合统计力学，Bose-Einstein分布和Debye近似的态密度分布，可以得到Debye热容为</p>

\[\begin{equation}
\begin{aligned}
C_V&amp;=\sum_qk_B\left(\frac{\hbar w_q}{k_BT}\right)^2\frac{\exp(\frac{\hbar w_q}{k_BT})}{\left(\exp(\frac{\hbar w_q}{k_BT})-1\right)^2}\\
&amp;=\int_0^{w_D}dw\cdot g(w) k_B\left(\frac{\hbar w}{k_BT}\right)^2\frac{\exp(\frac{\hbar w}{k_BT})}{\left(\exp(\frac{\hbar w}{k_BT})-1\right)^2}\\
(T\rightarrow0)\quad&amp;=12Nk_B\left(\frac{T}{T_D}\right)^2\int_0^{\infty}\frac{e^x x^3}{(e^x-1)^2}dx
\end{aligned}
\end{equation}\]

<p>以上得到在低温时， <strong>$Debye$ 热容正比于 $T^2$</strong></p>

<h2 id="44-debye-model-修正">4.4 Debye Model 修正</h2>

<p>从下图可以看到，对于 ZA 模，色散关系更加接近二次关系</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/project_x_w.png" width="40%" />
    <br />
</center>

<p>而且实际的Debye温度 $T_D^{exp}=2100K$,与 4.4.2中求出 $1273.24K$ 相比，差距比较大，</p>

<p>所以对态密度矩阵进行修正，考虑二次色散关系</p>

\[w_{ZA}=\alpha q^2\\
g_{ZA}(w)=\frac{S}{4\pi \alpha}\]

<p>那么此时总态密度函数可以写作</p>

\[\begin{equation}
\begin{aligned}
g(w)&amp;=\frac{S\omega}{2\pi}\left(\frac1{v_{TA}^2}+\frac1{v_{LA}^2}\right)+\frac{S}{4\pi \alpha}=\frac{S\omega}{\pi v_g^2}+\frac{S}{4\pi \alpha}
\end{aligned}
\end{equation}\]

<p>同理，由于总态数目的限制，得到Debye频率：</p>

\[\int_0^{\omega_D}g(w)dw=6N\\
\omega_D\approx 3.36148\times10^{14}\]

<p>有此得到修正的 $Debye$ 温度 $T_D=\frac{\hbar w_D}{k_B}\approx2557.65K$，比较接近实验值 $T_D^{exp}=2100K$</p>

<p>此时可以得到热容的表达式</p>

\[\begin{equation}
\begin{aligned}
C_V&amp;=\int_0^{w_D}dw\cdot g(w) k_B\left(\frac{\hbar w}{k_BT}\right)^2\frac{\exp(\frac{\hbar w}{k_BT})}{\left(\exp(\frac{\hbar w}{k_BT})-1\right)^2}\\
(T\rightarrow0)\quad&amp;=\left(\frac{k_B^3S}{\pi v_g^2\hbar^2}\int_0^\infty\frac{e^x x^3}{(e^x-1)^2}dx\right)\times T^2+
\left(\frac{k_B^2S}{4\pi \alpha\hbar}\int_0^\infty\frac{e^xx^2}{(e^x-1)^2}dx\right)\times T\\
&amp;=AT^2+BT
\end{aligned}
\end{equation}\]

<p>可以看到在极低温处，<strong>热容应当是与温度呈线性</strong>，其中 $A=5.8\times10^{-5},B=2.6\times 10^{-2}$,修正后图像如下，在 $0-100K$ 范围内保持了良好的线性</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/fit_Cp_100.png" width="40%" />
    <br />
</center>

<h2 id="4-5-实际热容">4. 5 实际热容</h2>

<p>根据晶格动力学求解出的态密度分布：</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/DOS.png" width="40%" />
    <br />
</center>

<p>结合统计力学和Bose-Einstein分布：</p>

\[C_V=\sum_qk_B\left(\frac{\hbar w_q}{k_BT}\right)^2\frac{\exp(\frac{\hbar w_q}{k_BT})}{\left(\exp(\frac{\hbar w_q}{k_BT})-1\right)^2}\]

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Cp_2000.png" width="35%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Cp_100.png" width="35%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4.8. 热容随温度变化
    </div>
    <p> </p>
</center>

<p>可以看到在低温处，比热容确实保持了线性，这正是 $ZA$ 模式下色散关系在呈现二次关系导致的</p>

<p>文献中给出的热容如下：</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/实际热容.png" width="40%" />
    <br />
</center>

<h1 id="5-电子特性">5. 电子特性</h1>

<h2 id="51-sommerfeld-自由电子论">5.1 Sommerfeld 自由电子论</h2>

<p>如果按照Sommerfeld的自由电子气理论，可以计算二维石墨烯结构在T= 0K 处的费米能、费米半径、费米速度：</p>

\[\begin{align}
k_F=\sqrt{4\pi n}=1.54\times10^{10} m^{-1}\\
E_F=\frac{\hbar^2k_F^2}{2m}=9.14eV\\
v_F=\frac{\hbar k_F}{m}=1.78\times10^6m/s
\end{align}\]

<p>不过石墨烯并不是经典意义上的金属，其费米半径是大于第一布里渊区心到边界的距离</p>

\[k_{min}=\pi/a\approx1.28\times10^{10}m^{-1}\]

<h2 id="52-紧束缚近似">5.2 紧束缚近似</h2>

<p>按照紧束缚近似，认为电子主要在原子附近，下面考虑 $\pi $ 电子的能带, 设总本征态为 $\vert{\Psi}\rangle$</p>

<p>由Schrödinger方程</p>

\[\widehat H|{\Psi_k}\rangle=E_k|{\Psi_k}\rangle\tag{5.1}\]

<p>设 $V(r)$ 是考虑所有晶格原子势场的结果, $u(r)$ 是一个中心碳原子的势场,那么有</p>

\[\begin{align}
\widehat H&amp;=-\frac{\hbar^2}{2m}\widehat p^2+V(\widehat r)\\
&amp;=-\frac{\hbar^2}{2m}\widehat p^2+\sum_{R_A}u(\widehat r-R_A)+\sum_{R_B}u(\widehat r-R_B)
\end{align}\]

<p>按照紧束缚近似理论，考虑总本征态 $\vert{\Psi } \rangle $ 是A原子和B原子本征态 $\vert\phi\rangle$ 的叠加：</p>

\[\begin{align}
|{\Psi_k}\rangle=C_A|{\phi_k^A}\rangle+C_B|{\phi_k^B}\rangle\\
|{\phi_k^A}\rangle=\frac1{\sqrt N}\sum_{R_A}e^{ikR_A}\varphi(r-R_A)\\
|{\phi_k^B}\rangle=\frac1{\sqrt N}\sum_{R_B}e^{ikR_B}\varphi(r-R_B)
\end{align}\]

<p>其中 $\vert \phi\rangle$ 是一个孤立电子和原子核之间的 $2p$轨道的本征态</p>

\[\widehat H|\varphi\rangle=-\frac{\hbar^2}{2m}\widehat p^2+u(\widehat r)|\varphi\rangle=\varepsilon_{2p}|\varphi\rangle\]

<p>对（44）分别左乘 $\langle{\phi_k^A}\vert,\langle{\phi_k^B\vert}$，得到如下形式的方程组</p>

\[(H_{AA}-E_kS_{AA})C_A+(H_{AB}-E_kS_{AB})C_B=0\\
(H_{BA}-E_kS_{BA})C_A+(H_{BB}-E_kS_{BB})C_B=0\]

<p>如果写成矩阵的形式：</p>

\[(H-E_kS)\begin{bmatrix}C_A\\C_B\end{bmatrix}=0\]

<p>下面分别来看 $H_{\alpha\beta},S_{\alpha\beta}$ 的表达式: ($\alpha,\beta \in{A,B}$)</p>

<p>对于 $H_{AA}$，只考虑自身相互作用,有如下表达</p>

\[\begin{equation}
\begin{aligned}
H_{AA}=\langle{\phi_k^A}|\widehat H|{\phi_k^A}\rangle&amp;=\frac1N\sum_{i=1}^N\sum_{j=1}^Ne^{ik(R_{Ai}-R_{Aj})}\langle\varphi(r-R_{Ai})|\widehat H|{\varphi(r-R_{Aj})\rangle)}\\
&amp;=\frac1N\sum_{i=1}^N\langle\varphi(r-R_{Ai})|\widehat H|\varphi(r-R_{Ai}\rangle\\
&amp;\approx\varepsilon_{2p}
\end{aligned}
\end{equation}\]

<p>同理 $H _ {BB}\approx\varepsilon _ {2p}$</p>

<p>对于 $H _ { AB}$，有如下表达</p>

\[\begin{equation}
\begin{aligned}
H_{AB}&amp;=\langle{\phi_k^A}|\widehat H|{\phi_k^B}\rangle\\

&amp;=\frac1N\sum_{i=1}^N\sum_{j=1}^Ne^{ik(R_{Ai}-R_{Bj})}\langle\varphi(r-R_{Ai})|\widehat H|\varphi(r-R_{Bj})\rangle\\
\end{aligned}
\end{equation}\]

<p>对于此表达式，只考虑最邻近原子相互作用，如下:</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/graphene3.png" width="40%" />
    <br />
</center>

\[\delta_1=\frac{a_0}{2}(1,\sqrt3)=\frac{a}{2}(\frac{1}{\sqrt3},1)\\
\delta_2=\frac{a_0}{2}(1,-\sqrt3)=\frac{a}{2}(\frac{1}{\sqrt3},-1)\\
\delta_3=-a_0(1,0)=-a_0(\frac{1}{\sqrt 3},0)\]

<p>所以 $H_{AB}$ 可以得到：</p>

\[\begin{equation}
\begin{aligned}
H_{AB}&amp;=\frac1N\sum_i\sum_{\delta_i}e^{ik\delta_i}\langle\varphi(r-R_{Ai})|\widehat H|\varphi(r-R_{Bj})\rangle\\
&amp;=-\frac{\gamma_0}{N}\sum_if(\mathbf k)=-\gamma_0f(\mathbf k)
\end{aligned}
\end{equation}\]

<p>其中,由于对称性,与 $\delta$ 方向无关:</p>

\[\begin{equation}
\begin{aligned}
\gamma_0&amp;=-\langle\varphi(r-R_{Ai})|\widehat H |\varphi(r-R_{Bj})\rangle\\
&amp;=-\langle{\varphi(r)}|\widehat H |{\varphi(r+(R_{A_i}-R_{Bj})}\rangle\\
&amp;=-\langle{\varphi(r)}|\widehat H |{\varphi(r-\delta)}\rangle\\
\end{aligned}
\end{equation}\]

\[\begin{equation}
\begin{aligned}
f(\mathbf k)&amp;=\sum_{\delta_i}e^{-i\mathbf k \cdot \mathbf{\delta_i}}=e^{ik_xa/\sqrt3}+2e^{-ik_xa/2\sqrt3}\cos(k_ya/2)
\end{aligned}
\end{equation}\]

<p>由厄米性：$H_{AB}=H_{BA}^{*}$</p>

<p>同样得道理可以得到：</p>

\[S_{AA}=S_{BB}=1\\
S_{AB}=S_{BA}^*=-S_0f(\mathbf k)\\
S_0=-\langle{\varphi(r)}\vert{\varphi(r-\delta)}\rangle\]

<p>结合（46）式有解条件以及（47）（50）（53），有</p>

\[det(H-E_kS)=0\\
H=\begin{bmatrix}\varepsilon_{2p}&amp;-\gamma_0f(\mathbf k)\\
-\gamma_0f^*(\mathbf k)&amp;\varepsilon_{2p}
\end{bmatrix}\\
S=\begin{bmatrix}1&amp;-s_0f(\mathbf k)\\
-s_0f^*(\mathbf k)&amp;1
\end{bmatrix}\]

<p>得到方程的解为</p>

\[E_k=\frac{\varepsilon_{2p}\pm\gamma_0|f(\mathbf k)|}{1\mp s_0|f(\mathbf k)|}\]

<p>其中 $ \vert f(\mathbf k)\vert=\sqrt{1+4\cos(\sqrt3k_xa/2)\cos(k_ya/2)+4\cos^2(k_ya/2)}$ ；</p>

<p>查阅文献可得 $\bf{\gamma_0=3.033 eV,s_0=0.129eV}$，并取 $\varepsilon_{2p}=0eV$</p>

<p>根据(55)可以画出 $\pi $ 轨道的能带结构（ <code class="language-plaintext highlighter-rouge">energy_band.m</code>）</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/energy3D.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5.1. 能带结构
    </div>
    <p> </p>                  
</center>

<p>有时会近似忽略 $s_0$,即令 $s_0=0eV$,此时可以将能带结构简化为：</p>

\[E_k=\pm\gamma_0|f(\mathbf k)|\]

<h2 id="53-能态密度">5.3 能态密度</h2>

<p>由于已经求出了能带结构，很自然的可以画出能态密度（<code class="language-plaintext highlighter-rouge">DOS_energy.m</code>）</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/DOS_energy.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5.2. 能态密度
    </div>
    <p> </p>                  
</center>

<p>从文献中可以给出石墨烯能态密度的表达式</p>

\[\begin{equation}
\rho_g(\epsilon)=\left\{\begin{aligned}
&amp;0\quad &amp;\epsilon&lt;-\frac D2\\
&amp;-\frac{\rho_m}{2\epsilon}\Delta\quad&amp;-\frac D2&lt;\epsilon&lt;-\frac\Delta2\\
&amp;\frac{2\rho_m|\epsilon|}{\Delta}\quad&amp;-\frac\Delta2&lt;\epsilon&lt;\frac\Delta2\\
&amp;\frac{\rho_m}{2\epsilon}\Delta\quad&amp;\frac\Delta2&lt;\epsilon&lt;\frac D2\\
&amp;0\quad &amp;\frac D2&lt;\epsilon
\end{aligned}\right.
\end{equation}\]

<p>其中 $\rho_m=\frac{4}{[1+2\ln(D/\Delta)]\Delta},\Delta=6eV,D=18.4eV$ ，得到下图</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/DOS_model.png" width="40%" />
    <br />
</center>

<p>还有一种表示形式是：</p>

<center>
    <img src="/images/img_graphene/Formula.png" width="70%" />
    <br />
</center>

<p>其中 $\bf F(\pi/2,x)$ 是第一类椭圆积分，图像如下</p>

<center>
        <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/DOS_model2.png" width="60%" />
    <br />
</center>

<h2 id="54-van-hove-奇点">5.4 Van Hove 奇点</h2>

<p>对于 $M$ 处的电子态密度具有 Van Hove 奇点</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/energy2D_M.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5.3. Γ-M-Γ 二维能带结构
    </div>
    <p> </p>                  
</center>

<h2 id="55-dirac点">5.5 Dirac点</h2>

<p>如果只考虑到 $\pi $ 轨道的两个电子，从紧束缚近似模型中可以看到，两个电子自旋上下填满了的能量较低的能带；然而从图像中可以看到上下的价带和导带在 $K$ 点处接触，能隙为0，正是在此处，<strong>石墨烯具有了独特的半金属性</strong>。观察其二维平面能带：</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/energy2D_K.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5.4. K-Γ-K 二维能带结构
    </div>
    <p> </p>                  
</center>

<p>结合三维视图，可以看到在布里渊区边界处（K和K’点）有六个锥，<strong>这六个锥便是狄拉克锥（Dirac cone）。在每个锥上，上下能带简并在一个点，该点便称为狄拉克点（Dirac point)</strong>,这些点分别是</p>

\[(0,\pm\frac{4\pi}{3}),(\pm\frac{4\pi}{3},0 ),(\pm\frac{2\pi}{\sqrt 3 a},\pm\frac{2\pi}{3a}),(\pm\frac{2\pi}{\sqrt 3 a},\mp\frac{2\pi}{3a})\]

<p>在 $K,K’$ 点附近对(56)进行 $Taylor$ 展开，忽略高阶小量，能够得到如能量与动量线性关系：</p>

\[E_{\pm}=\pm\frac{\sqrt3\gamma_0 a}{2}\sqrt{(k_x-k_{Kx})^2+(k_y-k_{Ky})^2}=\pm v_F\hbar |\mathbf {k-k_K}|\]

<p>其中 $v_F\approx9.8\times 10^5 m/s\approx c/100 $，接近光速</p>

<p>在描述电子运动时，我们可以把一个在晶格内运动的电子等效为一个在自由空间中运动的电子。类似地引入有效质量的概念，将晶体中的场对于电子的影响等效于自由空间运动的电子的质量 $\frac1{m^*}\sim\frac{d^2 E}{dk^2}$ ，由于色散关系为线性，且在能量为零的点对称，导致 E(k) 在 K 点不连续，导致二阶导数无穷大，电子的有效质量为零。所以此时用薛定谔方程来描述粒子的运动已无效，应该运用引入了相对论效应的狄拉克方程来描述。</p>

\[\widehat H|{\Psi_k}\rangle=iv_F\sigma\cdot\nabla|{\Psi_k}\rangle=E_k|{\Psi_k}\rangle\]

<p>在 $K,K’$ 处的波函数为</p>

\[{\Psi_K(k)}=\frac1{\sqrt2}\begin{pmatrix}e^{-i\theta_k/2}\\
\pm e^{i\theta_k/2}
\end{pmatrix}\\
{\Psi_{K'}(k)}=\frac1{\sqrt2}\begin{pmatrix}e^{i\theta_k/2}\\
\pm e^{-i\theta_k/2}
\end{pmatrix}={\Psi_K^*(k)}\]

<p>这样的狄拉克费米子波函数有着很显著的隧穿效应，如下图所示，假设入射的波函数为</p>

\[{\Psi_K(k)}=\frac1{\sqrt2}\begin{pmatrix}1\\
\pm e^{i\theta_k}
\end{pmatrix}\]

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/Scatter.png" width="35%" />
       <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_graphene/T_phi.png" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5.5. 隧穿效应
    </div>
    <p> </p>                  
</center>

<p>透过率的表达式为</p>

\[T(\phi)=\frac{\cos^2\theta\cos^2\phi}{[\cos(Dq_x)\cos\phi\cos\theta]^2+\sin^2(Dq_x)(1-ss'\sin\phi\sin\theta)^2}\]

<p>其中</p>

\[\begin{align}
q_x=\sqrt{(V_0-E)^2/v_F^2-k_y^2}\\
\phi=\arctan(k_y/k_x)\\
\theta=\arctan(k_y/q_x)
\end{align}\]

<p>即使在 $\vert V_0\vert\gg \vert E\vert$时， 由边界条件得到穿透率为</p>

\[T(\phi)\approx\frac{\cos^2\phi}{1-\cos^2(Dq_x)}sin^2\phi\]

<p>当 $\phi$ 趋近于0时，透过率仍然接近1，这意味着石墨烯中的电子和空穴具有很长的自由程，电子受到温度的影响比较小，石墨烯具有很高的电子迁移率，因而<strong>石墨烯有良好的导电性</strong>。</p>

<h1 id="6-summary">6. Summary</h1>

<p>本次关于石墨烯的调研从石墨烯特殊的晶格结构出发，讨论晶体中常见的性质和参数：倒格矢，化学键和结合能等。利用晶格动力学求解了石墨烯色散关系，并利用色散关系讨论了石墨烯的杨氏模量、热容、态密度等性质，并发现石墨烯在低温下具有二次的色散关系，使得石墨烯具有良好的导热能量以及低温热容与温度成正比的关系。最后研究了石墨烯的电子特性，从索末菲的自由电子论出发，再到紧束缚近似求出石墨烯的能带结构，能态密度；并着重讨论石墨烯在倒易空间中的 $K$ 点处具有特别的性质，使得石墨烯呈现出半金属性和优良的导电能力。</p>

<h1 id="7-reference">7 Reference</h1>

<ol>
  <li><a href="https://www.semanticscholar.org/paper/Electronic-and-Thermal-Properties-of-Graphene-and-Sang-Shin/fd184c530f1b2e92a8ad647f4917a6f4763bb220">Sang, Mingyu, et al. “Electronic and thermal properties of graphene and  recent advances in graphene based electronics applications.” <em>Nanomaterials</em> 9.3 (2019): 374.</a></li>
  <li><a href="https://arxiv.org/abs/0709.1163">Neto, AH Castro, et al. “The electronic properties of graphene.” <em>Reviews of modern physics</em> 81.1 (2009): 109.</a></li>
  <li><a href="https://web.physics.ucsb.edu/~phys123B/w2015/pdf_CoursGraphene2008.pdf">Fuchs, Jean-Noel, and Mark Oliver Goerbig. “Introduction to the physical properties of graphene.” <em>Lecture notes</em> 10 (2008)</a></li>
  <li><a href="https://www.researchgate.net/publication/291339016_Thermodynamic_properties_of_pure_and_doped_B_N_graphene">Mann, Sarita, et al. “Thermodynamic properties of pure and doped (B, N) graphene.” <em>RSC advances</em> 6.15 (2016): 12158-12168.</a></li>
  <li><a href="https://arxiv.org/abs/1301.6181">Pop, Eric, Vikas Varshney, and Ajit K. Roy. “Thermal properties of graphene: Fundamentals and applications.” <em>MRS bulletin</em> 37.12 (2012): 1273-1281.</a></li>
  <li><a href="https://doi.org/10.1142/p080">Dresselhaus, G., Mildred S. Dresselhaus, and Riichiro Saito. <em>Physical properties of carbon nanotubes</em>. World scientific, 1998.</a></li>
  <li><a href="https://wulixb.iphy.ac.cn/pdf-content/10.7498/aps.63.154704.pdf">叶振强, 曹炳阳, and 过增元. “石墨烯的声子热学性质研究.” <em>物理学报</em> 63.15 (2014): 154704-154704.</a></li>
  <li><a href="https://www.sciencedirect.com/science/article/pii/S0749603615300239">Memarian, Farzaneh, A. Fereidoon, and M. Darvish Ganji. “Graphene Young’s modulus: Molecular mechanics and DFT treatments.” <em>Superlattices and Microstructures</em> 85 (2015): 348-356</a></li>
  <li><a href="https://www.tandfonline.com/doi/full/10.1080/14686996.2018.1494493">Yang, Gao, et al. “Structure of graphene and its disorders: a review.” <em>Science and technology of advanced materials</em> 19.1 (2018): 613-648.</a></li>
  <li><a href="https://www.researchgate.net/profile/Sergei-Davydov/publication/251341039_Model_of_adsorption_on_graphene/links/54994c3e0cf21eb3df5f9009/Model-of-adsorption-on-graphene.pdf">Davydov, S. Yu, and G. I. Sabirova. “Model of adsorption on graphene.” <em>Physics of the Solid State</em> 53 (2011): 654-664.</a></li>
  <li><a href="https://pip.nju.edu.cn/CN/abstract/abstract74.shtml">殷隆晶, 乔佳斌, and 何林. “双层转角石墨烯的结构和电学性质.” <em>物理学进展</em> 36.3 (2016): 65.</a></li>
</ol>]]></content><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><category term="Physics" /><summary type="html"><![CDATA[石墨烯是由碳原子构成的一种二维材料，具有许多独特的性质，包括出色的热学性质和电子性质。研究了石墨烯的晶格结构、色散关系、态密度、光学性质和输运性质。Graphene is a two-dimensional material with unique thermal and electronic properties.]]></summary></entry><entry><title type="html">Ray Path Tracing</title><link href="https://rainzor.github.io/blogs/ray-tracing" rel="alternate" type="text/html" title="Ray Path Tracing" /><published>2023-01-10T00:00:00+00:00</published><updated>2023-01-10T00:00:00+00:00</updated><id>https://rainzor.github.io/blogs/ray-tracing</id><content type="html" xml:base="https://rainzor.github.io/blogs/ray-tracing"><![CDATA[<p>Using Monte Carlo methods to solve the rendering equation for implementing ray-traced global illumination.</p>

<p>If you want to view the source code, you can search for them in my <a href="https://github.com/Rainzor/RayTracing">GitHub repository</a>.</p>

<h1 id="1-abstract">1. Abstract</h1>

<p>This article mainly introduces the use of Monte Carlo methods to solve the rendering equation. The rendering equation is decomposed into direct and indirect lighting, and Monte Carlo importance sampling is used for direct lighting, with the Alias algorithm used to accelerate sampling time. Indirect lighting is recursively solved, and the results for different samples per pixel (SPP) for each pixel are discussed.</p>

<p><strong>Keywords</strong> : Monte Carlo methods, global illumination, rendering equation, Alias algorithm</p>

<h1 id="2-introduction">2. Introduction</h1>

<h2 id="21-rendering-equation">2.1 Rendering Equation</h2>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/render_eq.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 1:Rendering
    </div>
    <p> </p>
</center>

\[L _ {o}(\pmb{p},\pmb{\omega} _ {o})=L _ {e}(\pmb{p},\pmb{\omega} _ {o})+\int _ {\mathcal{H}^2(\pmb{n}(\pmb{p}))} f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})L _ {i}(\pmb{p},\pmb{\omega} _ {i})\cos\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}\mathbb{d}\pmb{\omega} _ {i}\tag{1}\]

<p>Where:</p>

<blockquote>
  <ul>
    <li>$L _ {o}$ is the outgoing radiance</li>
    <li>$\pmb{p}$ is the rendering point</li>
    <li>$\pmb{\omega} _ {i}$ is the incident light direction</li>
    <li>$\pmb{\omega} _ {o}$ is the outgoing light direction</li>
    <li>$L _ {e}$ is the emissive radiance</li>
    <li>$\pmb{n}(\pmb{p})$ is the surface normal at point $\pmb{p}$</li>
    <li>${\mathcal{H}^2(\pmb{n}(\pmb{p}))} $ is the hemisphere with normal $\pmb{n}(\pmb{p})$</li>
    <li>$f _ {r}$ is the bidirectional scattering distribution function (BRDF)</li>
    <li>$L _ {i}$ is the incoming radiance</li>
    <li>$\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}$ is the angle between $\pmb{\omega} _ {i}$ and $\pmb{n}(\pmb{p})$.</li>
  </ul>
</blockquote>

<p>The reflection equation is defined as:
\(L _ {r}(\pmb{p},\pmb{\omega} _ {o})=\int _ {\mathcal{H}^2(\pmb{n}(\pmb{p}))} f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})L_i(\pmb{p},\pmb{\omega} _ {i})\cos\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}\mathbb{d}\pmb{\omega} _ {i}\tag{2}\)
Therefore, the rendering equation can be rewritten as:
\(L _ {o}(\pmb{p},\pmb{\omega} _ {o})=L _ {e}(\pmb{p},\pmb{\omega} _ {o})+L _ {r}(\pmb{p},\pmb{\omega} _ {o})\)
As $L _ {e}(\pmb{p},\pmb{\omega} _ {o})$ represents the intensity of object’s self-emission and can be treated as a known quantity, we assume that no objects other than the light source emit light spontaneously. Therefore, we only need to focus on the reflected light intensity $L _ {r}(\pmb{p},\pmb{\omega} _ {o})$. This can be expressed as:
\(L _ {o}(\pmb{p},\pmb{\omega} _ {o})=L _ {r}(\pmb{p},\pmb{\omega} _ {o})\tag{3}\)
In <em>equation (2)</em>, the reflected light $L _ {r}(\pmb{p},\pmb{\omega} _ {o})$ actually comes from two parts:</p>

<ul>
  <li>Direct illumination from the light source, called <strong>direct light</strong>, denoted as $L _ {\text{dir}}(\pmb{p},\pmb{\omega} _ {o})$;</li>
  <li>Indirect illumination from other objects, called <strong>indirect light</strong>, denoted as $L _ {\text{indir}}(\pmb{p},\pmb{\omega} _ {o})$.</li>
</ul>

\[L_o=L_r(\pmb{p},\pmb{\omega} _ {o})=L _ {\text{dir}}(\pmb{p},\pmb{\omega} _ {o})+L _ {\text{indir}}(\pmb{p},\pmb{\omega} _ {o})\tag{4}\]

<p>In the <em>equation (4)</em>, $-\pmb{\omega} _ {i}$ is the outgoing direction for $L_{\text{dir}}$ and $L_{\text{indir}}$.</p>

<h2 id="22-direct-lighting">2.2 Direct Lighting</h2>

<h3 id="221-lighting-equation-for-light-sources">2.2.1 Lighting Equation for Light Sources</h3>

\[L _ {\text{dir}}(\pmb{p},\pmb{\omega} _ {o})=\int _ {\mathcal{H}^2(\pmb{n}(\pmb{p}))}L _ {e}(\pmb{p},-\pmb{\omega} _ {i})f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})\cos\theta\mathbb{d}\pmb{\omega} _ {i} \tag5\]

<p>For the light source $L_e$, the outgoing light direction is $\pmb{\omega} _ {e,o}=-\pmb{\omega} _ {i}$.</p>

<p>The position $\pmb{p}$, outgoing direction $\pmb{\omega} _ {o}$, and incoming direction $\pmb{\omega} _ {i}$ can be determined by three points, as shown in the following figure:</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/xyz.jpg" width="30%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/dwi_dA.jpg" width="33%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 2
    </div>
    <p> </p>
</center>

<blockquote>
  <p>Note: In the figure, $\pmb{x}$ represents $\pmb{p}$, and $\pmb{y}$ represents $\pmb{p}^\prime$.</p>
</blockquote>

<p>If we only integrate at the original lighting point $\pmb{p}$, we are sampling solid angles on a hemisphere, which leads to a lot of optical directions being wasted. Therefore, we should integrate directly over the region where the light source is located, i.e., the integration limit changes from a hemisphere to the surface area of the light source!
\(L _ {\text{dir}}(\pmb{p},\pmb{\omega} _ {o})=L _ {\text{dir}}(\pmb{x}\to\pmb{z})=\int _ A f _ {r}(\pmb{y}\to \pmb{x}\to\pmb{z})L _ {e}(\pmb{y}\to\pmb{x})G(\pmb{x}\leftrightarrow\pmb{y})\mathbb{d}A(\pmb{y})\tag6\)
Here, the integration domain $A$ includes all surfaces in the scene, but only at the position of the light source $L _ {e}(\pmb{y}\to\pmb{x})\neq 0$.</p>

<p>By applying the <strong>Monte Carlo integration method</strong>, we get:
\(L _ {\text{dir}}(\pmb{x}\to\pmb{z})=\sum _ {A(i,j)}\frac{ f _ {r}(\pmb{y}\to \pmb{x}\to\pmb{z})L _ {e}(\pmb{y}\to\pmb{x})G(\pmb{x}\leftrightarrow\pmb{y})}{p(i,j)}\tag7\)
Where, $p(i,j)$ is a <strong>uniformly sampled</strong> point on the surface of the light source region $A$.</p>

<p>By changing variables in the integral using <em>eq(5)</em> and <em>eq (6)</em>, we get:</p>

\[\mathbb{d}\pmb{\omega} _ {i}=\frac{|\cos\theta _ {\pmb{y},\pmb{x}}|}{\|\pmb{x}-\pmb{y}\|^2}\mathbb{d}A(\pmb{y})\]

<p>Where, $\theta _ {\pmb{y},\pmb{x}}$ represents the angle between the direction $\pmb{x}-\pmb{y}$ and the normal vector $\pmb{n}(\pmb{y})$ at point $\pmb{y}$. We introduce a geometric term to represent the “transport efficiency” between the two points:</p>

\[G(\pmb{x}\leftrightarrow\pmb{y})=V(\pmb{x}\leftrightarrow\pmb{y})\frac{|\cos\theta _ {\pmb{x},\pmb{y}}||\cos\theta _ {\pmb{y},\pmb{x}}|}{\|\pmb{x}-\pmb{y}\|^2}\]

<p>Where, $V(\pmb{x}\leftrightarrow\pmb{y})$ is a visibility function, which is 1 if there is no occlusion between $\pmb{x}$ and $\pmb{y}$, and 0 otherwise. $G$ is a symmetric function, meaning that $G(\pmb{x}\leftrightarrow\pmb{y})=G(\pmb{y}\leftrightarrow\pmb{x})$.</p>

<p>If we denote the number of light sources in the scene as $N_e$, the set of light sources as ${L _ {e _ {i}}} _ {i=1}^{N _ {e}}$, and the corresponding regions as ${A(L _ {e _ {i}})} _ {i=1}^{N _ {e}}$, then we can write the equation as:
\(\begin{aligned}
L _ {\text{dir}}(\pmb{x}\to\pmb{z})&amp;=\sum _ {k=1}^{N _ {e}}\int _ {A(L _ {e _ {k}})} f _ {r}(\pmb{y}\to\pmb{x}\to\pmb{z})L _ {e}(\pmb{y}\to\pmb{x})G(\pmb{x}\to\pmb{y})\mathbb{d}A(\pmb{y})\\
&amp;=\sum _ {i=k}^{N _ {e}}\sum_ {A_k(i,j)} \frac{f _ {r}(\pmb{y}\to\pmb{x}\to\pmb{z})L _ {e}(\pmb{y}\to\pmb{x})G(\pmb{x}\to\pmb{y})}{p_k(i,j)}
\end{aligned}\tag8\)</p>

<h3 id="222-importance-sampling-for-environment-map">2.2.2 Importance Sampling for Environment Map</h3>

<h4 id="monte-carlo-importance-sampling">Monte Carlo Importance Sampling</h4>

<p>In addition to being emitted from the light sources we specify, direct lighting can also come from ambient illumination in the surroundings. When sampling the environment map, if we uniformly sample all regions of the environment map, we will lose a lot of information from regions with high radiance. Therefore, we should use Monte Carlo importance sampling to focus on sampling regions with higher radiance, as shown in the figure below.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/important_sample.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 3: MC Important Sampling
    </div>
    <p> </p>
</center>

<p>The so-called importance sampling means that the selected sampling probability density approximately conforms to the distribution to be sampled. For a given environment map, if the sampling is at pixel point $\pmb{y}=(i,j)$, the probability of that point is denoted as $p _ {img}(i,j)$.
\(p_{img}(i,j)=\frac{L_e(i,j)}{\sum_{k,l}L_e(k,l)}\tag9\)
The relevant probability relationships are as follows:</p>

\[\begin{aligned}
1=\int _ {I}p _ {\text{img}}(i,j)\mathbb{d}i\mathbb{d}j
&amp;=\int _ {\Theta}p _ {\text{img}}(\theta,\phi)\left|\frac{\partial(i,j)}{\partial(\theta,\phi)}\right|\mathbb{d}\theta\mathbb{d}\phi\newline 
&amp;=\int _ {A}p _ {\text{img}}(A)\left|\det J _ A\Theta\right|\left|\frac{\partial(i,j)}{\partial(\theta,\phi)}\right|\mathbb{d}A\newline 
&amp;=\int _ {\mathcal{H}^2}p _ {\text{img}}(\pmb{\omega} _ {i})\left|\frac{\mathrm{d}A}{\mathrm{d}\pmb{\omega} _ {i}}\right|\left|\det J _ A{\Theta}\right|\left|\frac{\partial(i,j)}{\partial(\theta,\phi)}\right|\mathbb{d}\pmb{\omega} _ {i}\newline 
&amp;=\int _ {\mathcal{H}^2}p(\pmb{\omega} _ {i})\mathbb{d}\pmb{\omega} _ {i}\newline 
\end{aligned}\]

<p>According to <em>Figure 2</em> and the correspondence between environment map, we have:</p>

\[\begin{aligned}
&amp;\left|\frac{\mathrm{d}\pmb{\omega} _ {i}}{\mathrm{d}A}\right|=\frac{|\cos\theta _ {o}|}{\|\pmb{x}-\pmb{y}\|^2}=\frac{1}{R^2}\\
&amp;\left|\det J _ A\Theta\right|=\frac{1}{R^2\sin\theta}\\
&amp;\left|\frac{\partial(i,j)}{\partial(\theta,\phi)}\right|=\frac{wh}{2\pi^2}
\end{aligned}\]

<p>where:</p>

<blockquote>
  <ul>
    <li>$i \in [0, w]$，$w$ is the image width.</li>
    <li>$j\in[0,h]$，$h$ is the image height.</li>
    <li>
      <p>$u,v\in[0,1]$，and $u=i/w$, $v=j/h$.</p>
    </li>
    <li>$\theta\in[0,\pi]$，$\theta=\pi(1-v)$</li>
    <li>$\phi\in[0,2\pi]$，$\phi=2\pi u$</li>
    <li>$\pmb{\omega} _ i=(\sin\theta\sin\phi,\cos\theta,\sin\theta\cos\phi)$</li>
  </ul>
</blockquote>

<p>So that:
\(p(\pmb{\omega} _ {i})=\frac{wh}{2\pi^2\sin\theta}p _ {\text{img}}(i,j)\tag{10}\)
At this point, <em>eq (6)</em> can be rewritten as:
\(\begin{aligned}
L _ {\text{dir}}(\pmb{p},\pmb{\omega} _ {o})&amp;=\int _ A f _ {r}(\pmb{y}\to \pmb{x}\to\pmb{z})L _ {e}(\pmb{y}\to\pmb{x})G(\pmb{x}\leftrightarrow\pmb{y})\mathbb{d}A(\pmb{y})
\\&amp;=\int _ {\mathcal{H}^2}\frac{ f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})L_i(\pmb{p},\pmb{\omega} _ {i})\cos\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}}{p(\pmb{\omega} _ {i})}\times p(\pmb{\omega} _ {i})\mathbb{d}\pmb{\omega} _ {i}
\\&amp;=\int _ {I}\frac{ f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})L_e(\pmb{p},\pmb{\omega} _ {i})\cos\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}}{p(\pmb{\omega} _ {i})}\times p _ {\text{img}}(i,j)\mathbb{d}i\mathbb{d}j
\\&amp;=\sum_{I_{i,j}}\frac{ f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})L_e(\pmb{p},\pmb{\omega} _ {i})\cos\theta _ {\pmb{\omega} _ {i},\pmb{n}(\pmb{p})}}{p _ {\text{img}}(i,j)}\times \frac{2\pi^2\sin\theta}{wh}
\end{aligned}\tag{11}\)
The summation is a discrete sampling based on the importance distribution $p_{img}(i,j)$ obtained by importance sampling.</p>

<h4 id="alias-method">Alias Method</h4>

<p>If the size of the environment map is $m=width \times height=n\times n$ pixels, the average time complexity of obtaining a sample point using conventional discrete sampling is $O(m)$. The Alias Method can reduce the time complexity of discrete sampling to $O(1)$. The specific steps are as follows:</p>

<h5 id="initialize-table">Initialize Table</h5>

<ol>
  <li>
    <p>Suppose the initial probability distribution table is $U(k=i * n + j)=p(i,j) * m$, alias table $K_k =k$, where $k\in[0,m)$, and initialize two queues A and B to store the node numbers whose $U_k$ are less than 1 and greater than 1, respectively.</p>
  </li>
  <li>
    <p>Pop a value $a=A.pop(), b=B.pop()$ from A and B queues, respectively.</p>
  </li>
  <li>
    <p>Modify the probability distribution table: $U(b) = U(b) - (1 - U(a))$; modify the alias table: $K_k=b$.</p>
  </li>
  <li>
    <p>If $U(b)&lt;1$, add the element b to the A queue: $A.push(b)$</p>

    <p>If $U(b)&gt;1$, add the element b to the B queue: $B.pushback(b)$</p>
  </li>
  <li>
    <p>If A and B are both empty, end the process; otherwise, return to step 1.</p>
  </li>
</ol>

<h5 id="sample-operation">Sample Operation</h5>

<ol>
  <li>
    <p>Generate two random numbers $\xi_1, \xi_2 \in [0, 1)$.</p>
  </li>
  <li>
    <p>Let $k_1 = \lfloor m * \xi_1 \rfloor \in { 0, 1, 2, 3, …, m-1 }$.</p>
  </li>
  <li>
    <p>If $\xi_2 \le U(k_1)$, then the sampled point is $(i, j) = (k_1%n, k_1/n)$.</p>

    <p>Otherwise, let $k_2 = K(k_1)$, and the sampled point is $(i, j) = (k_2%n, k_2/n)$.</p>
  </li>
</ol>

<p>The sampling time complexity of this algorithm is $O(1)$.</p>

<h2 id="23-indirect-lighting">2.3 Indirect Lighting</h2>

<h3 id="231-indirect-lighting-equation">2.3.1 Indirect Lighting Equation</h3>

<p>In addition to computing direct lighting, “indirect lighting” must also be calculated.
\(\begin{aligned}
L _ {\text{indir}}(\pmb{p},\pmb{\omega} _ {o})
=\int _ {\mathcal{H}^2(\pmb{n}(\pmb{p}))}L _ {r}(\pmb{p},-\pmb{\omega} _ {i})f _ {r}(\pmb{p},\pmb{\omega} _ {i},\pmb{\omega} _ {o})\cos\theta\mathbb{d}\pmb{\omega} _ {i}
\end{aligned}\tag{12}\)</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/indirect.png" width="75%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4: Indirect Light
    </div>
    <p> </p>
</center>

<p>If we look back at <em>equation 4</em>, we will find that <strong>indirect lighting requires recursion!</strong></p>

<p>Assume that the camera is located at point O and the light source is at point T. We want to calculate the radiance of point P projected onto point O. We perform Path Tracing along the OPQ path:</p>

<ul>
  <li>If no object is encountered, the recursion ends, and $L_o=L_r=L_{\text{dir}}$.</li>
  <li>If an object is encountered, we can regard Q as the light source. Then, we solve the <strong>first rendering equation</strong> for the OPQ segment. The incident radiance <strong>Li(p,ωi)</strong> at point P in the integrand of the equation is unknown, but this incident radiance <strong>Li</strong> at point P is also the outgoing radiance <strong>Lo</strong> at point Q. We can then solve the <strong>second rendering equation</strong> along the PQT path. We keep recursing until we encounter the environment or the light source.</li>
</ul>

<h3 id="232-the-exponential-explosion-problem">2.3.2 The exponential explosion problem</h3>

<ol>
  <li>
    <p>As the number of bounces increases, the number of rays traced grows exponentially with N, the number of samples taken for each incoming direction. As a result, the recursion stack grows exponentially with the increase in recursion depth.</p>

    <p><strong>Solution:</strong> The recursion explosion problem only occurs when N &gt; 1. To avoid it, we only choose one incoming direction at random instead of N directions.</p>
  </li>
  <li>
    <p>In the natural world, light bounces an infinite number of times, but setting an upper limit on the number of bounces will inevitably result in a loss of energy. So how can we avoid infinite recursion and energy loss?</p>

    <p><strong>Solution:</strong> Russian Roulette (RR)</p>

    <ul>
      <li>Our goal is to calculate the shading result of a shading point, i.e., the <strong>Lo</strong> in the camera direction.</li>
      <li>Assume we manually set a probability <strong>P</strong> (0 &lt; P &lt; 1). We emit another ray with a probability of P and return the shading result of <strong>Lo/P</strong>. We do not emit another ray with a probability of 1 - P and return <strong>0</strong>.</li>
      <li>Finally, the expected value of the discrete random variable is calculated as: $E = P \times (Lo / P) + (1 - P) \times 0$.</li>
    </ul>
  </li>
  <li>
    <p>Since we only randomly sample one incoming direction, there may be a lot of noise. Some shading points may not hit the light source or other objects, even if the random incoming direction is sampled and calculated.</p>

    <p><strong>Solution:</strong> Increase the samples per pixel (SPP) by tracing more paths per pixel and averaging them. Therefore, by tracing enough paths, there is a greater chance of hitting a valid light source or object, resulting in a closer approximation to the correct shading.</p>
  </li>
</ol>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/spp.png" width="75%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 5: Compare spp
    </div>
    <p> </p>
</center>
<h2 id="24-algorithm">2.4 Algorithm</h2>

<p>So far, we have obtained all the algorithms for solving <em>equation 1</em>, in pseudo-code form as follows:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">Shade</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="n">wo</span><span class="p">)</span><span class="o">:</span>
	<span class="c1">// 1、Direct illumination from light sources and ambient light.</span>
    <span class="n">Uniformly</span> <span class="n">sampling</span> <span class="n">a</span> <span class="n">point</span> <span class="n">on</span> <span class="n">the</span> <span class="n">surface</span> <span class="n">of</span> <span class="n">the</span> <span class="n">light</span> <span class="n">source</span><span class="o">:</span> <span class="n">x</span><span class="err">'</span><span class="p">;</span>   
	<span class="n">shoot</span> <span class="n">a</span> <span class="n">ray</span> <span class="n">form</span> <span class="n">p</span> <span class="n">to</span> <span class="n">x</span><span class="err">'</span><span class="p">;</span>
	<span class="n">L_dir</span> <span class="o">=</span> <span class="mi">0</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span>	
	<span class="k">if</span> <span class="p">(</span><span class="n">the</span> <span class="n">ray</span> <span class="n">is</span> <span class="n">not</span> <span class="n">blocked</span> <span class="n">in</span> <span class="n">the</span> <span class="n">middle</span><span class="p">)</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">the</span> <span class="n">ray</span> <span class="n">from</span> <span class="n">source</span> <span class="n">light</span><span class="p">)</span>
			<span class="n">L_dir</span> <span class="o">+=</span> <span class="n">L_e</span> <span class="o">*</span> <span class="n">f_r</span> <span class="o">*</span> <span class="n">cos</span><span class="err">θ</span> <span class="o">*</span> <span class="n">cos</span><span class="err">θ'</span> <span class="o">/</span> <span class="o">|</span><span class="n">x</span><span class="err">'</span> <span class="o">-</span> <span class="n">p</span><span class="o">|^</span><span class="mi">2</span> <span class="o">/</span> <span class="n">pdf_light</span><span class="p">;</span>
    	<span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="n">the</span> <span class="n">ray</span> <span class="n">from</span> <span class="n">environment</span> <span class="n">backgroud</span><span class="p">)</span>
            <span class="n">L_dir</span> <span class="o">+=</span> <span class="n">L_e</span> <span class="o">*</span> <span class="n">f_r</span> <span class="o">*</span> <span class="n">cos</span><span class="err">θ</span> <span class="o">/</span> <span class="n">pdf_env</span> <span class="o">*</span> <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">pi</span><span class="o">*</span><span class="mi">2</span><span class="n">pi</span><span class="o">*</span><span class="n">sin</span><span class="err">θ</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">w</span><span class="o">*</span><span class="n">h</span><span class="p">)</span>
	<span class="c1">//2、Indirect illumination from other objects.</span>
	<span class="n">L_indir</span> <span class="o">=</span> <span class="mi">0</span><span class="p">.</span><span class="mi">0</span><span class="p">;</span>
	<span class="n">Test</span> <span class="n">Russian</span> <span class="n">Roulette</span> <span class="n">with</span> <span class="n">probability</span> <span class="n">P_RR</span><span class="p">;</span>
	<span class="n">Uniformly</span> <span class="n">sample</span> <span class="n">the</span> <span class="n">hemisphere</span> <span class="n">toward</span> <span class="n">wi</span><span class="p">;</span>  
	<span class="n">Trace</span> <span class="n">a</span> <span class="n">ray</span> <span class="nf">r</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="n">wi</span><span class="p">);</span>
	<span class="k">if</span> <span class="p">(</span><span class="n">ray</span> <span class="n">r</span> <span class="n">hit</span> <span class="n">a</span> <span class="n">non</span><span class="o">-</span><span class="n">emitting</span> <span class="n">object</span> <span class="n">at</span> <span class="n">q</span><span class="p">)</span>
	    <span class="n">L_indir</span> <span class="o">=</span> <span class="n">shade</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="o">-</span><span class="n">wi</span><span class="p">)</span> <span class="o">*</span> <span class="n">f_r</span> <span class="o">*</span> <span class="n">cos</span><span class="err">θ</span> <span class="o">/</span> <span class="n">pdf_hemi</span> <span class="o">/</span> <span class="n">P_RR</span><span class="p">;</span> 
    <span class="k">return</span> <span class="n">L_dir</span> <span class="o">+</span> <span class="n">L_indir</span><span class="p">;</span>
</code></pre></div></div>

<h1 id="3-result">3 Result</h1>

<h2 id="31-low-spp">3.1 low SPP</h2>

<p>We simulate at low number of samples per pixel (SPP = 4).</p>

<h3 id="311-direct-lighting-only">3.1.1 Direct Lighting Only</h3>

<p>First, consider only the direct lighting model
\(L_o=L_{dir}\)</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/rst_dir.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 6: Only direct light
    </div>
    <p> </p>
</center>
<p>Result analysis: The effect of adding only direct lighting is not good for high reflectivity metal spheres, but it can already display the image basically.</p>

<h3 id="312-global-illumination">3.1.2 Global Illumination</h3>

<p>Now we add indirect lighting, which means
\(L_o=L_{\text{dir}}+L_{\text{indir}}\)</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/rst_global.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 7: Global Illumination
    </div>
    <p> </p>
</center>
<p>Result Analysis: By adding indirect illumination, the metal sphere looks more realistic in the global illumination model and can clearly reflect patterns of other objects.</p>

<h3 id="313-monte-carlo-importance-sampling">3.1.3 Monte Carlo Importance Sampling</h3>

<p>Let’s consider importance sampling for the environmental light.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/rst_global_impSamp.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 8: Global Illumination by important sampling
    </div>
    <p> </p>
</center>
<p>Results analysis: When importance sampling is applied to environmental lighting, the noise in the image is reduced and the shadows in the image are better displayed.</p>

<h2 id="32-high-spp">3.2 High SPP</h2>

<p>Finally, we increase the number of SPP to 1024 and display the results.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_ray_tracing/rst_high_spp.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 9:Global Illumination with high spp
    </div>
    <p> </p>
</center>

<p>Result Analysis: With an increasing number of optical tracks being tracked, the scene has become very realistic, successfully rendering the image.</p>

<h1 id="4-summary">4 Summary</h1>

<p>This article first analyzes the principles of the rendering equation and provides a reasonable decomposition of the rendering equation.</p>

<p>Then, we introduce how to use the Monte Carlo integration method for sampling, namely, the method of directly sampling the illumination and importance sampling by varying the sampling regions, and improves the sampling efficiency with the help of the Alias algorithm. The experimental results show that importance sampling has a good effect on improving image quality.</p>

<p>Next, the article elaborates on the method of recursively solving indirect illumination and proposes a series of methods to prevent the problem of exponential explosion.</p>

<p>Finally, after increasing the number of samples for each pixel, the image can successfully render the results.</p>

<h1 id="5-reference">5. Reference</h1>

<p>[1] <a href="https://github.com/Ubpa/USTC_CG/tree/master/Homeworks/9_PathTracing">Code Framework</a></p>]]></content><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><category term="Computer Graphics" /><summary type="html"><![CDATA[This article mainly introduces the use of Monte Carlo methods to solve the rendering equation. The rendering equation is decomposed into direct and indirect lighting, and Monte Carlo importance sampling is used for direct lighting, with the Alias algorithm used to accelerate sampling time. Indirect lighting is recursively solved. Keywords: Monte Carlo methods, global illumination, rendering equation, Alias algorithm.]]></summary></entry><entry><title type="html">Poisson Image Editing</title><link href="https://rainzor.github.io/blogs/poisson-image" rel="alternate" type="text/html" title="Poisson Image Editing" /><published>2022-11-14T00:00:00+00:00</published><updated>2022-11-14T00:00:00+00:00</updated><id>https://rainzor.github.io/blogs/poisson-image</id><content type="html" xml:base="https://rainzor.github.io/blogs/poisson-image"><![CDATA[<p>Seamlessly blend the image into the environment.</p>

<p>If you want to view the source code, you can search for them in my <a href="https://github.com/Rainzor/PoissonImageEditing">GitHub repository</a>.</p>

<p>中文版本可以参见这个链接 <a href="https://github.com/Rainzor/USTC_CG_2023s/tree/master/03_poisson_editing">click here</a></p>

<h1 id="1-abstract">1 Abstract</h1>

<p>Implementing image boundary determination based on the scan-line algorithm. And using a general interpolation mechanism based on solving the Poisson equation allows for seamless import of opaque and transparent source image regions into the target region.</p>

<p><strong>Keywords</strong>: Interactive image editing, scanning line algorithm, Poisson equation</p>

<h1 id="2-target">2 Target</h1>

<p>As shown in the figure, $f$ is the image to be blended with the domain defined in $\Omega$, and $f^*$ is the background image with the domain defined in $S$. The problem to be solved is to allow them to blend naturally. The so-called natural blending means that, while maintaining the original internal gradients of the image (minimizing the difference in gradients between the new and original images), the boundary values of the pasted image are the same as those of the new background image, in order to achieve a seamless paste effect.</p>

<p align="center">
    <img src="/images/img_poisson_image_editing/target.png" width="200" />
</p>

<h1 id="3-experiment">3 Experiment</h1>

<h2 id="31-polygon-scan-conversion-algorithm">3.1 Polygon scan conversion algorithm</h2>

<p>To better determine the boundary $\partial \Omega$ and the domain $\Omega$ to be solved, it is necessary to obtain a polygon interior mask through the scanline algorithm.</p>

<p><em>The sorted edge table method</em> defines special data structures for the edge table ET and the active edge table AET, avoiding the need for intersection calculations.</p>

<h3 id="active-edge-table-aet">Active Edge Table (AET）</h3>

<p>This table stores the edges that intersect with the current scanline. Before leaving one scanline and entering the next one, the edges in the table that do not intersect with the next scanline are removed, and the edges that intersect with the next scanline but are not in the table are added to the table. The edges in the <strong>active edge table (AET) are always sorted in increasing order of their x-coordinates</strong>, because when filling the polygon, it is necessary to determine whether the algorithm is entering or exiting the interior of the polygon based on this order.</p>

<ul>
  <li>ymax: The y-coordinate value of the highest scanline that the edge intersects.</li>
  <li>x: The coordinate of the intersection point between the current scanline and the edge.</li>
  <li>Δx:The increment of x from the current scanline to the next scanline.</li>
  <li>next: A pointer to the next edge.</li>
</ul>

<h3 id="edge-table-et">Edge Table (ET)</h3>

<p>(1) Before filling a polygon, it is necessary to first create an edge table to store information about the polygon’s edges. The edge table is a type of adjacency list. The entries in the <strong>edge table (ET)</strong> are sorted in increasing order of their y-coordinates, and the “bucket” under each entry is sorted in increasing order of their x-coordinates. The content of each item in the “bucket” is:</p>

<ul>
  <li>The maximum y-coordinate (ymax) of the edge’s other endpoint.</li>
  <li>The x-coordinate (xmin) of the endpoint corresponding to the smaller y-coordinate.</li>
  <li>The reciprocal of the slope (1/m).</li>
  <li>A pointer (next) to the next edge.</li>
</ul>

<p align="center">
    <img src="/images/img_poisson_image_editing/bucket.jpg" width="200" />
</p>

<p>(2) Note: When creating the edge table, if a vertex appears to be a local maximum or minimum (e.g., point B in the figure below), it is treated as two separate points; otherwise, it is treated as a single point. In practice, local maximum or minimum vertices do not need to be processed, while other vertices should be moved inward along the edge direction by one unit.</p>

<p>The reason is as follows: For example, in the figure below, for point B, no extra processing is needed because when the scanline is at y=9, both e2 and e3 will be included in the AET. That is, point B will appear twice in the current AET, and when filling, it will enter and exit at that point, avoiding any filling errors. However, for point A, if it is not moved inward, when the scanline is at y=3, both e1 and e2 will be included in the AET. Therefore, point A will also appear twice in the current AET, resulting in three points in the AET and causing an error in the filling of the polygon interior after the row y=3. In addition, the AET should always contain an even number of points. After moving inward, point A will only appear once in the current AET, and there will be an even number of points, resulting in correct filling.</p>

<p align="center">
    <img src="/images/img_poisson_image_editing/edge.png" width="400" />
</p>

<p>（3）The established ET is shown below:</p>

<p align="center">
    <img src="/images/img_poisson_image_editing/ET.png" width="400" />
</p>

<p>Note that e2 and e5 have been indented here, while e1, e3, and e4 have not.</p>

<h3 id="scanning-process">Scanning process</h3>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_poisson_image_editing/AET.png" width="50%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure :Active Edge Table
    </div>
    <p> </p>
</center>

<h3 id="fill-algorithm">Fill algorithm</h3>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kt">void</span> <span class="nf">Polygonfill</span><span class="p">(</span><span class="n">EdgeTable</span> <span class="n">ET</span><span class="p">,</span>  <span class="n">COLORREF</span> <span class="n">color</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">the</span> <span class="n">minimum</span> <span class="n">value</span> <span class="n">of</span> <span class="n">y</span> <span class="n">coordinates</span> <span class="n">among</span> <span class="n">all</span> <span class="n">the</span> <span class="n">registered</span> <span class="n">items</span> <span class="n">in</span> <span class="n">the</span> <span class="n">edge</span> <span class="n">table</span> <span class="p">(</span><span class="n">ET</span><span class="p">).</span>
    <span class="n">Initialize</span> <span class="n">the</span> <span class="n">active</span> <span class="n">edge</span> <span class="n">table</span> <span class="p">(</span><span class="n">AET</span><span class="p">)</span> <span class="n">as</span> <span class="n">an</span> <span class="n">empty</span> <span class="n">table</span><span class="p">.</span>
    <span class="k">while</span> <span class="p">(</span><span class="n">there</span> <span class="n">are</span> <span class="n">still</span> <span class="n">scan</span> <span class="n">lines</span> <span class="n">in</span> <span class="n">the</span> <span class="n">ET</span> <span class="n">that</span> <span class="n">have</span> <span class="n">not</span> <span class="n">been</span> <span class="n">processed</span><span class="p">)</span> <span class="c1">// process each scan line in the ET</span>
    <span class="p">{</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">1</span> <span class="n">Merge</span> <span class="n">all</span> <span class="n">the</span> <span class="s">"buckets"</span> <span class="n">corresponding</span> <span class="n">to</span> <span class="n">the</span> <span class="n">y</span> <span class="n">coordinate</span> <span class="n">in</span> <span class="n">the</span> <span class="n">ET</span> <span class="n">into</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span><span class="p">,</span>
    <span class="n">sort</span> <span class="n">the</span> <span class="n">buckets</span> <span class="n">in</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span> <span class="n">by</span> <span class="n">increasing</span> <span class="n">x</span> <span class="n">coordinate</span><span class="p">.</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">2</span> <span class="n">On</span> <span class="n">the</span> <span class="n">scan</span> <span class="n">line</span> <span class="n">y</span><span class="p">,</span> <span class="n">perform</span> <span class="n">fill</span> <span class="n">using</span> <span class="n">the</span> <span class="n">color</span> <span class="n">according</span> <span class="n">to</span> <span class="n">the</span> <span class="n">x</span> <span class="n">coordinates</span> <span class="n">provided</span> <span class="n">by</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span><span class="p">.</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">3</span> <span class="n">Clear</span> <span class="n">all</span> <span class="n">the</span> <span class="n">items</span> <span class="n">in</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span> <span class="n">that</span> <span class="n">have</span> <span class="n">y</span> <span class="o">=</span> <span class="n">ymax</span><span class="p">.</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">4</span> <span class="n">For</span> <span class="n">the</span> <span class="n">remaining</span> <span class="n">items</span> <span class="n">in</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span><span class="p">,</span> <span class="n">replace</span> <span class="n">x</span> <span class="n">with</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="n">m</span><span class="p">.</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">5</span> <span class="n">Since</span> <span class="n">the</span> <span class="n">previous</span> <span class="n">step</span> <span class="n">may</span> <span class="n">have</span> <span class="n">disrupted</span> <span class="n">the</span> <span class="n">increasing</span> <span class="n">order</span> <span class="n">of</span> <span class="n">x</span> <span class="n">coordinates</span> <span class="n">in</span> <span class="n">the</span> <span class="n">AET</span> <span class="n">table</span><span class="p">,</span>
    <span class="n">re</span><span class="o">-</span><span class="n">sort</span> <span class="n">the</span> <span class="n">table</span> <span class="n">by</span> <span class="n">x</span> <span class="n">coordinate</span><span class="p">.</span> <span class="c1">// for non-simple polygons</span>
    <span class="mi">3</span><span class="p">.</span><span class="mi">6</span> <span class="n">Increment</span> <span class="n">y</span> <span class="n">by</span> <span class="mi">1</span> <span class="n">and</span> <span class="n">move</span> <span class="n">on</span> <span class="n">to</span> <span class="n">the</span> <span class="n">next</span> <span class="n">scan</span> <span class="n">line</span><span class="p">.</span>
  	<span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<h2 id="32-image-fusion-algorithm">3.2 Image Fusion Algorithm</h2>

<h3 id="mathematical-formulation">Mathematical Formulation</h3>

<p>Mathematically, image fusion can be formulated as the solution to the optimization problem of embedding the new image $f(x,y)$ into a new background $f^ * (x,y)$ , given the original image $g(x,y)$, as follows:</p>

<p>\(\begin{equation}
		\min\limits_f \iint _\Omega |\nabla f-\nabla g |^2 \ \ \mathrm{with}\ f|_{\partial \Omega}=f^*|_{\partial \Omega}
	\end{equation}\tag1\)
By using the variational method and applying the Euler-Lagrange equation, the problem can be transformed into a Poisson equation with Dirichlet boundary conditions:
\(\begin{equation}
		\Delta f= \Delta  g\ \mathrm{over}\ \Omega \ \ \mathrm{with}\ f|_{\partial \Omega}=f^*|_{\partial \Omega}
	\end{equation}\tag2\)
If we let $\widetilde f = f - g$ and $(f^ * - g) = \varphi$, then the problem can be transformed into solving the boundary problem of Laplace’s equation:</p>

\[\begin{equation}
		\Delta \widetilde f= 0\ \mathrm{over}\ \Omega \ \ \mathrm{with}\widetilde f|_{\partial \Omega}=(f^*-g)|_{\partial \Omega}=\varphi|_{\partial \Omega}
	\end{equation}\tag3\]

<p>Here, $f^*, g$ and $\varphi$ are known boundary conditions, while $\widetilde f$ is the function to be solved.</p>

<h3 id="numerical-equation">Numerical Equation</h3>

<p>To perform numerical solutions, $\Delta f$ needs to be discretized using the finite difference method. Assuming a pixel spacing of $h=1$ for any point $\mathbf p=(i,j)$ in region $S$ with corresponding $f$ value denoted as $f_p$, the equation is as follows:
\(\Delta f_p\approx\frac{4f(i,j)-f(i+1,j)-f(i-1,j)-f(i,j+1)-f(i,j-1)}{4h^2}\tag4\)
For the sake of simplicity, let $N_p$ denote the four-connected neighborhood of each pixel $p$ in $S$. Let $\left&lt;p,q\right&gt;$ denote a pair of pixels such that $q \in N_p$, i.e., $q \in {(i+1,j),(i-1,j),(i,j+1),(i,j-1)}$. With this, we can obtain the numerical equation solution.
\(\begin{equation}
		\mathrm{for}\ \mathrm{all}\ p\in \Omega,\ |N_p|\widetilde f_p-\sum\limits_{q\in N_p\cap \Omega} \widetilde f_q=\sum\limits_{q\in N_p\cap \partial \Omega}\varphi_p
	\end{equation}\tag5\)</p>

<h3 id="matrix-form-equation">Matrix Form Equation</h3>

<p>Set $\widetilde f_{ij}=u_{ij},\varphi_p=\varphi_{ij}$, so that:
\(4u_{i,j}-u_{i,j-1}-u_{i-1,j}-u_{i+1,j}-u_{i,j+1}=0\quad(i,j)\in \Omega\backslash\partial\Omega\tag6\)</p>

\[u_{k,l}=\varphi(k,l)\quad (k,l)\in\partial\Omega\tag7\]

<p>If we take a rectangular region as an example, let 
\(\Omega={(i,j)|0\le i\le m,0\le j\le m}\)
In this case, there are a total of $(m+1)\times (n+1)$ unknowns $u_{ij}$ in equations (5) and (6), and a total of $(m+1)\times (n+1)$ constraint conditions. These conditions are linearly independent, so the system is solvable.</p>

<p>For a more general boundary, the algorithm can be described as follows:</p>

<ol>
  <li>Initialization: Let there be a total of $N$ pixel points in $I=\Omega\backslash\partial\Omega$. Initialize a sparse $N\times N$ coefficient matrix <code class="language-plaintext highlighter-rouge">coe_sparse_mat=0</code> and an N-dimensional unknown vector <code class="language-plaintext highlighter-rouge">vec</code>. Assume that the region $S$ has $n\times m$ pixel points and begin from the starting point.</li>
  <li>Traverse each pixel point $(i,j)$ in the region $S$.</li>
  <li>If $(i,j)\in I$, then <code class="language-plaintext highlighter-rouge">index(i,j)=i*n+j</code>
    <ul>
      <li><code class="language-plaintext highlighter-rouge">coe_sparse_mat[index(i,j)][index(i,j)]= 4</code></li>
      <li>If a surrounding point $\mathbf q\in I$, then <code class="language-plaintext highlighter-rouge">coe_sparse_mat(q)=-1</code></li>
      <li>If a surrounding point $\mathbf q\in E=\partial\Omega$, then <code class="language-plaintext highlighter-rouge">vec[index(q)]=</code>$\varphi$<code class="language-plaintext highlighter-rouge">[index(q)]</code></li>
    </ul>
  </li>
  <li>Solve the equation <code class="language-plaintext highlighter-rouge">coe_sparse_mat</code> * <code class="language-plaintext highlighter-rouge">x</code>=<code class="language-plaintext highlighter-rouge">vec</code>, where <code class="language-plaintext highlighter-rouge">x(index(i,j)) = u(i,j)</code>.</li>
</ol>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// Step 1: Initialization</span>
<span class="n">N</span> <span class="o">=</span> <span class="n">number</span> <span class="n">of</span> <span class="n">pixel</span> <span class="n">points</span> <span class="n">in</span> <span class="n">D</span>
<span class="n">coe_sparse_mat</span> <span class="o">=</span> <span class="n">sparse</span> <span class="n">N</span> <span class="n">x</span> <span class="n">N</span> <span class="n">matrix</span>
<span class="n">vec</span> <span class="o">=</span> <span class="n">N</span><span class="o">-</span><span class="n">dimensional</span> <span class="n">vector</span>
<span class="n">n</span> <span class="o">=</span> <span class="n">number</span> <span class="n">of</span> <span class="n">pixels</span> <span class="n">along</span> <span class="n">x</span><span class="o">-</span><span class="n">axis</span> <span class="n">in</span> <span class="n">S</span>
<span class="n">m</span> <span class="o">=</span> <span class="n">number</span> <span class="n">of</span> <span class="n">pixels</span> <span class="n">along</span> <span class="n">y</span><span class="o">-</span><span class="n">axis</span> <span class="n">in</span> <span class="n">S</span>

<span class="c1">// Step 2: Traverse pixel points in S</span>
<span class="k">for</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span> <span class="n">to</span> <span class="n">m</span><span class="o">:</span>
    <span class="k">for</span> <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span> <span class="n">to</span> <span class="n">n</span><span class="o">:</span>
    
        <span class="c1">// Step 3: Check if pixel point is in D</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">)</span> <span class="n">is</span> <span class="n">in</span> <span class="n">D</span><span class="o">:</span>
            <span class="n">index</span> <span class="o">=</span> <span class="n">i</span> <span class="o">*</span> <span class="n">n</span> <span class="o">+</span> <span class="n">j</span>
            <span class="n">coe_sparse_mat</span><span class="p">[</span><span class="n">index</span><span class="p">][</span><span class="n">index</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
            
            <span class="c1">// Check surrounding points in Interior</span>
            <span class="k">for</span> <span class="n">each</span> <span class="n">surrounding</span> <span class="n">point</span> <span class="n">q</span><span class="o">:</span>
                <span class="k">if</span> <span class="n">q</span> <span class="n">is</span> <span class="n">in</span> <span class="n">D</span><span class="o">:</span>
                    <span class="n">coe_sparse_mat</span><span class="p">[</span><span class="n">index</span><span class="p">][</span><span class="n">index</span><span class="p">(</span><span class="n">q</span><span class="p">)]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
                <span class="n">elif</span> <span class="n">q</span> <span class="n">is</span> <span class="n">in</span> <span class="n">E</span><span class="o">:</span><span class="c1">//if q in edge</span>
                    <span class="n">vec</span><span class="p">[</span><span class="n">index</span><span class="p">(</span><span class="n">q</span><span class="p">)]</span> <span class="o">=</span> <span class="n">phi</span><span class="p">[</span><span class="n">index</span><span class="p">(</span><span class="n">q</span><span class="p">)]</span>
                    
<span class="c1">// Step 4: Solve equation coe_sparse_mat * x = vec</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">solve</span><span class="p">(</span><span class="n">coe_sparse_mat</span><span class="p">,</span> <span class="n">vec</span><span class="p">)</span>
</code></pre></div></div>

<p>The final solution is $\widetilde f_{ij}=u_{ij}$, and the pixel value of the resulting image is:</p>

\[f(i,j)=\widetilde f(i,j)+g(i,j)\]

<p>Where $g(i,j)$ is the pixel value of the original image, and $\widetilde f(i,j)$ is the value just obtained after solving.</p>

<h1 id="4-result">4 Result</h1>

<p>There is a girl happily swimming in the swimming pool, while a bear is swimming in another river. They are in different bodies of water, as shown in the following pictures.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_poisson_image_editing/GirlInWater.jpg" width="25%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_poisson_image_editing/BearInWater.jpg" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Left:girl in the pool.Right: bear in the river
    </div>
    <p> </p>
</center>

<p>Now we put these two unlucky guys into the ocean. If we simply copy and paste, the following result would occur:</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_poisson_image_editing/normal_paste.bmp" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Simple Paste
    </div>
    <p> </p>
</center>

<p>However, with the help of our Poisson fusion image algorithm, they can be more naturally integrated into the ocean：</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_poisson_image_editing/Poisson_paste.bmp" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Poisson Paste
    </div>
    <p> </p>
</center>

<p>As you can see, the images match the surrounding environment more naturally after using our algorithm, but there is still room for improvement!</p>

<h1 id="5-reference">5. Reference</h1>

<ul>
  <li><a href="https://ezeli.github.io/2019/08/26/%E5%9B%9B%E3%80%81%E5%A4%9A%E8%BE%B9%E5%BD%A2%E7%9A%84%E6%89%AB%E6%8F%8F%E8%BD%AC%E6%8D%A2%E7%AE%97%E6%B3%95%E5%8E%9F%E7%90%86%E5%92%8C%E5%AE%9E%E8%B7%B5/">Polygon Scan Conversion Algorithm</a></li>
  <li><a href="https://www.cs.jhu.edu/~misha/Fall07/Papers/Perez03.pdf">Poisson Image Editing Algorithm</a></li>
  <li><a href="https://github.com/Ubpa/USTC_CG/tree/master/Homeworks/3_PoissonImageEditing">Code Framework</a></li>
</ul>]]></content><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><category term="Computer Graphics" /><summary type="html"><![CDATA[Implementing image boundary determination based on the scan-line algorithm. Using a general interpolation mechanism based on solving the Poisson equation allows for seamless import of opaque and transparent source image regions into the target region. Keywords: Interactive image editing, scanning line algorithm, Poisson equation.]]></summary></entry><entry><title type="html">Growth Model</title><link href="https://rainzor.github.io/blogs/growth-model" rel="alternate" type="text/html" title="Growth Model" /><published>2022-10-03T00:00:00+00:00</published><updated>2022-10-03T00:00:00+00:00</updated><id>https://rainzor.github.io/blogs/Growth-Model</id><content type="html" xml:base="https://rainzor.github.io/blogs/growth-model"><![CDATA[<p>DLA(Diffusion Limited Aggregation) and DBM(The Dielectric Breakdown Model)</p>

<p>If you want to view the source code, you can search for them in my <a href="https://github.com/Rainzor/GrowthModel">GitHub repository</a>.</p>

<h1 id="1abstract">1.Abstract</h1>

<p>DLA(Diffusion Limited Aggregation) and DBM(The Dielectric Breakdown Model) are two commonly used non-equilibrium growth models. DLA is a classic model for non-equilibrium growth, used to study natural phenomena such as crystal growth, fluid dynamics, and dust aggregation. On the other hand, DBM is a model for dielectric breakdown phenomena, used to predict breakdown behavior in materials by considering physical processes such as the density evolution of ionized electrons and electron holes. Despite being applied in different fields, both models share the common feature of non-equilibrium growth, where the evolution of physical processes does not satisfy thermodynamic equilibrium conditions.</p>

<p>In this article ,I simulated 2D DLA and DBM patterns, and discussed image’s fractal and dimensional features.</p>

<p><strong>Keywords</strong> : Random walking,growth model, Laplace Equation, fractals and fractal dimensions</p>

<h1 id="2method">2.Method</h1>

<h2 id="21-dla">2.1 DLA</h2>

<p>The DLA model is one of the classic models for describing non-equilibrium growth, and its basic idea is that particles with random motion deposit on an adsorption center to form a dense shell in an initial state. New particles diffuse and move along the surface of the shell, and if they collide with a certain point of the original shell, they will stop and be adsorbed, continuing to form the next layer of the shell. The DLA model is commonly used to study non-equilibrium growth phenomena in nature, such as crystal growth, fluid dynamics, and dust aggregation.</p>

<p align="center">
  <img src="/images/img_growth_model/gif/DLA.gif" width="400" height="400" />
</p>

<h3 id="simulation-rules">Simulation Rules</h3>

<p>A 2D square lattice is taken, and a particle is placed at the center of the lattice as the seed for growth. Another particle is released from a circular boundary far enough from the origin of the lattice and allowed to perform a random walk. The particle will eventually collide with the nearest neighbor position of the seed, at which point the particle will stick to the seed and stop moving. If the particle reaches the boundary of the lattice, it is considered a useless trajectory and discarded, and a new particle is generated. Therefore, useful particles that stick to the seed form a growing aggregate cluster.</p>

<h5 id="definitions">Definitions:</h5>

<ul>
  <li>The maximum distance of the current aggregate cluster is <strong>d</strong>.</li>
  <li>The cluster radius is $r=\max({20, d})$.</li>
  <li>The edge length of the 2D square matrix is $N$.</li>
  <li>The particle stickiness is $stickness \in (0,1)$.</li>
  <li>The radius of the generating circle is $R=2r$.</li>
</ul>

<h5 id="algorithm">Algorithm:</h5>

<ol>
  <li>Randomly generate a particle, $x$.
    <ul>
      <li>If $R&lt;N/2$, generate a particle randomly on a circle with radius $R$.</li>
      <li>Otherwise, generate a particle randomly on the boundary of the square lattice.</li>
    </ul>
  </li>
  <li>Let particle $x$ perform a random walk and check if there are any aggregate particles in the eight surrounding points.
    <ul>
      <li>If the particle collides with the boundary of the lattice, return to step 1 and generate a new particle.</li>
      <li>If there are aggregate particles nearby, determine whether to join the cluster or continue to perform a random walk based on the stickiness of $x$.</li>
    </ul>
  </li>
  <li>When the particle joins the cluster, update the cluster radius, $r$.</li>
  <li>Return to step 1, or end the program when the cluster is large enough.</li>
</ol>

<h2 id="22-dbm">2.2 DBM</h2>

<p>The DBM model is a model that describes the dielectric breakdown phenomenon. When an external electric field reaches a certain strength in a dielectric material, the electrons inside the material are subjected to a strong enough electric field force and collide with ionized electrons, resulting in local breakdown. The DBM model establishes the evolution equation of the ionized electron and electron hole densities in the dielectric material by considering physical processes such as free electrons, positive ions, and electron holes in the material, which predicts the breakdown behavior in the material. The DBM model is commonly used in the design of electrical equipment, optoelectronic devices, semiconductor materials, and so on.</p>

<h3 id="simulation-rules-1">Simulation Rules</h3>

<p>The process described by this model involves a constant potential $\phi_0$ at the central point of a dielectric material (insulator), which continuously breaks down the surrounding medium, forming a growing conductor.</p>

<p>The growth rate $v$ of breakdown in the medium is a function of the gradient of potential $\phi$, i.e., $v=f(\nabla_n\phi)$, where $n$ is normal to the interface. The potential throughout the medium follows Laplace’s equation, and the boundary conditions are that the potential is $\phi_0$ on the occupied grid and 0 at a distance. The growth mode is to occupy an empty grid on the boundary with a probability equal to the growth rate. Mathematically, this can be described as:
\(Growth Rate::v_{i,j}=n|\phi_0-\phi_{i,j}|^{\eta}\tag{1}\)</p>

\[Selection Probability:p_{i,j}=v_{i,j}/\sum v_{i,j}\tag{2}\]

<p>The probability is summed over all unoccupied grids on the boundary, and a grid is selected for occupation based on this probability. After occupying a new grid, the boundary conditions change, and the potential distribution, growth rate, and selection probability need to be recalculated.</p>

<h5 id="definitions-1">Definitions</h5>

<ul>
  <li>Grid state: <strong><code class="language-plaintext highlighter-rouge">EMPTY</code></strong> represents a free point, <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong> represents a candidate point, and <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong> represents a grown point.</li>
  <li>Particle set <strong><code class="language-plaintext highlighter-rouge">_particle_set</code></strong>: stores a set of generated points, all of which have the state <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong>.</li>
  <li>Candidate set <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>: stores a set of candidate points to be grown, all of which have the state <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong>.</li>
</ul>

<h5 id="algorithm-1">Algorithm</h5>

<ol>
  <li>Using formula (1) and (2), randomly select a candidate point <strong>x</strong> from <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong> based on its growth rate.</li>
  <li>Add the candidate point <strong>x</strong> to <strong><code class="language-plaintext highlighter-rouge">_particle_set</code></strong>, change its state from <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong> to <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong>, and set its potential to $\phi_0$.</li>
  <li>Add all surrounding <strong><code class="language-plaintext highlighter-rouge">EMPTY</code></strong> points of <strong>x</strong> to <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>, changing their state from <strong><code class="language-plaintext highlighter-rouge">EMPTY</code></strong> to <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong>.</li>
  <li>Remove <strong>x</strong> from <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>.</li>
  <li>Recalculate the potential of particles in <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong> based on Laplace’s equation and the new boundary conditions.</li>
  <li>Go back to step 1, or terminate the program when the cluster is large enough.</li>
</ol>

<p><strong>Note:</strong> In actual code implementation, it is not necessary to label points with states. The state can be determined based on whether a point is in <strong><code class="language-plaintext highlighter-rouge">_particle_set</code></strong> or <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>.</p>

<p><em>Numerical Solution Method for Laplace’s Equation:</em></p>

<p>The Laplace equation can be expressed as</p>

\[\nabla^2\phi(x,y)=0,\phi|_{\partial{D}}=f(x,y)\]

<p>For numerical solution, it can be written as
\(\phi_{i,j}=(\phi_{i-1,j}+\phi_{i+1,j}+\phi_{i,j-1}+\phi_{i,j+1})/4\)
In reality, the potential values of the surrounding points are not known, only the potential values on the boundaries are known. Therefore, particles at position (i, j) are allowed to randomly walk until they encounter the boundary, at which point the potential value on the boundary, denoted as $f(x,y)$, is recorded. After multiple random walks, the average potential value is taken as the potential value at point (i, j):
\(\left&lt;\phi_{i,j}\right&gt;=\frac1N\sum_n^N f_n(x,y)\)</p>

<h2 id="23-dbm_fast">2.3 DBM_FAST</h2>

<p align="center">
  <img src="/images/img_growth_model/gif/DBM_FAST.gif" width="400" height="400" />
</p>

<h3 id="background">Background</h3>

<p>For actual dielectric breakdown models, the main bottleneck of the algorithm is to re-calculate the potential size of <strong>all candidate points</strong> after each iteration. When the boundary range <strong>N</strong> is large enough to grow <strong>n</strong> points, the time complexity required is $O(n*N^3)$ <a href="https://chat.openai.com/chat#refer-anchor-1">1</a>. For a grid point with a side length of $N=300$, the time will be very slow, and it takes about 18 minutes to grow <strong>n=300</strong> points.</p>

<p>Therefore, based on the idea of a paper about <strong>fast Laplace growth simulation</strong> <a href="https://chat.openai.com/chat#refer-anchor-1">1</a>, I propose the following improvements.</p>

<h3 id="idea">Idea</h3>

<p>Each “grown” point is insulated, that is, the charge is not redistributed but fixed at the lattice point. For the potential of candidate points, it is a linear superposition of the electric potential of these <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong> growth points.</p>

<p>Consider that the center potential of the boundary is 1 and the potential at infinity is 0. Then, each point charge can be treated as a positive charge, and the potential is
\(\phi(r)=\frac{R_1}{r}\)
where the length of each small lattice point is $h$, and the radius of the point charge is $R_1=h/2$.</p>

<p>Therefore, for the <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong> point $i$, its potential is the superposition of the electric charge $j$ of all <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong> points:
\(\phi_i=\sum_{j=1}^n\frac{R_1}{r_{i,j}}\tag{3}\)
The growth rate should also be correspondingly corrected. Let the maximum potential of the <code class="language-plaintext highlighter-rouge">candidate</code> be $\phi_{max}$, and the minimum potential be $\phi_{min}$:
\(v_i = \left(\frac{\phi_{max}-\phi}{\phi_{max}-\phi_{min}}\right)^{\eta}\tag{4}\)
The reason why it can be accelerated is that each time it is iterated, the previous potential can be used for iteration, that is:
\(v_i = \left(\frac{\phi_{max}-\phi}{\phi_{max}-\phi_{min}}\right)^{\eta}\tag{4}\)
$r_{t+1}$ is the distance between the new position of the <code class="language-plaintext highlighter-rouge">FILLED</code> point and each <code class="language-plaintext highlighter-rouge">CANDIDATE</code> point.</p>

<h5 id="algorithm-2">Algorithm</h5>

<ol>
  <li>According to formula (4), the growth rate of the candidate point is a probability. After normalization, randomly select a candidate point <strong>x</strong> from the <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>.</li>
  <li>Add candidate point <strong>x</strong> to <strong><code class="language-plaintext highlighter-rouge">_particle_set</code></strong>, and its state changes from <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong> to <strong><code class="language-plaintext highlighter-rouge">FILLED</code></strong>.</li>
  <li>Remove <strong>x</strong> from <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>.</li>
  <li>Iterate the potential in <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong> according to formula (5).</li>
  <li>Add <strong><code class="language-plaintext highlighter-rouge">EMPTY</code></strong> points around <strong>x</strong> to <strong><code class="language-plaintext highlighter-rouge">_candidate_set</code></strong>, change the state from <strong><code class="language-plaintext highlighter-rouge">EMPTY</code></strong> to <strong><code class="language-plaintext highlighter-rouge">CANDIDATE</code></strong>, and calculate the potential of the new candidate point according to formula (3). In one iteration, no more than 5 points like this.</li>
  <li>Return to step 1; or when the cluster is large enough, the program ends.</li>
</ol>

<h2 id="24-code-framework">2.4 Code Framework</h2>

<p>Due to the need for efficiency in the code involving a large number of operations to check whether points are in a set, we have chosen <code class="language-plaintext highlighter-rouge">set</code> as the primary data structure. Its operations of searching with <code class="language-plaintext highlighter-rouge">in</code>, adding with <code class="language-plaintext highlighter-rouge">add</code>, and removing with <code class="language-plaintext highlighter-rouge">remove</code> are all with a time complexity of $0(1)$.</p>

<p>Since the three growth models have similar ideas, a class inheritance framework is designed.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/code_framework.png" width="25%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 1:Code Framework
    </div>
    <p> </p>
</center>

<p>The lower-level classes inherit the interface of the upper-level classes, reducing redundant code.</p>

<h2 id="25-fractal-and-dimensional-features">2.5 Fractal and Dimensional Features</h2>

<h3 id="sandbox-method">Sandbox Method</h3>

<p>Using the Sandbox method to calculate the fractal digits, the formula is</p>

\[N(r)\sim r^D\\
D = \frac{\ln N}{\ln r}+C\]

<p>N is the number of pixels in the square box, r is the side length of the box, and C is other constants. The statistical process is shown in the figure below</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/SandBoxMethod.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 2: Sandbox Method
    </div>
    <p> </p>
</center>

<p>Increase the side length of the box according to the power of $\sqrt 2$, count the number of internal points, and get a logarithmic coordinate graph, and calculate the slope to be the number of fractal digits D</p>

<h3 id="density-density-correlation-function-method">Density-Density Correlation Function Method</h3>

<p>The density-density correlation function of fractal patterns in the plane is defined as follows:</p>

\[C(r) = \left&lt;\sum \frac{\rho(r')\rho(r' + r)}{N}\right&gt; \sim r^{-\alpha}\]

<p>where $\rho(r’)$ is the density function of the pattern, which is 1 at the position of the pattern and 0 elsewhere; N is the total number of pixels. The geometric meaning of C(r) is the ratio of the number of overlapping pixels between the original pattern and the pattern translated by r to the total number of pixels, which represents the probability of finding another pixel at a distance r. In actual calculations, the average is taken over N different values of r’, as well as over different directions and lengths of r with the same length.</p>

<p>In the special case where r’ is fixed and taken as the center of the pattern (i.e., r’ = 0), we have:</p>

\[C(r) = \left&lt;\sum \rho(0)\rho(r)\right&gt; \sim r^{-\alpha}\]

<p>To determine the fractal dimension, we need to count the number of overlapping pixels within a circle with radius increasing by a power of $\sqrt 2$, plot the results on a logarithmic scale, and obtain the slope $\alpha$.</p>

<p>When integrating C(r) within the turning radius R, the integral value is proportional to the total number of pixels in the pattern when R is large enough.</p>

\[\int_0^RC(r)\text{d}^{dim}r\sim N\\
N\sim R^{dim-\alpha}\\
D=dim-\alpha\]

<p>“dim” refers to the Euclidean dimension of the space, which is 2 in this figure; “D” refers to the fractal dimension.</p>

<h1 id="3-experiment">3. Experiment</h1>

<h2 id="31-dla">3.1 DLA</h2>

<p>As shown in the following figure, DLA models were considered with viscosities of 0.01, 0.1, 0.5, and 1, respectively, and 3000 points were grown.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DLA_0.01_3000.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DLA_0.1_3000.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
    </div>
    <p> </p>
</center>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DLA_0.5_3000.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DLA_1_3000.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 3. Comparison of DLA with different stickiness values (3000 points).
    </div>
    <p> </p>
</center>

<h3 id="dla-analysis">DLA Analysis：</h3>

<p>As shown in the figure, as the viscosity increases, the image of DLA growth becomes increasingly sparse. When the viscosity is 1, particles are likely to collide with an external dendrite before entering a trench, resulting in a shielding effect and preventing particles from entering the trench. This structure reflects the characteristics of the growth process, where growth occurs faster at the tips, leading to the formation of branches that extend outward, and slower in flatter areas, resulting in a loose structure with gaps in the trenches. This morphology only appears when particles adhere to the cluster without any preferred direction.</p>

<h2 id="32-dbm">3.2 DBM</h2>

<p>As shown in the following figure, DBM models were considered with eta values of 0, 3, 6, and 10, respectively, and only 300 points were grown due to limited code efficiency.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_0_300.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_3_300.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
    </div>
    <p> </p>
</center>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_6_300.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_10_300.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
		Figure 4: Comparison of DBM with different values of eta (300 points).
</div>
    <p> </p>
</center>

<h3 id="analysis-of-dbm">Analysis of DBM:</h3>

<p>From the images, it can be observed that as $\eta$ increases and the growth rate 
\(v_ {i,j}=n|\phi_0-\phi_ {i,j}|^{\eta}\)
chooses branches based on probability, the number of branches gradually decreases, and the image converges from a two-dimensional uniform plane to a one-dimensional image, just like from a spherical lightning to a linear lightning.</p>

<p>This phenomenon can be easily explained by analysis. As $\eta$ increases, for larger potential energy gradients 
\(|\phi_0-\phi_{i,j}|\)
 their weight becomes more prominent, leading to a greater probability of choosing the direction with a greater change in gradient. Therefore, it is easier to present a linear image with fewer branches.</p>

<h2 id="33-dbm_fast">3.3 DBM_FAST</h2>

<p>After improving the algorithm, DBM models with $\eta$ values of 0, 3, 6, and 10 were obtained, and 3000 points were grown to produce the following images.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_0_3000.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_3_3000.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
    </div>
    <p> </p>
</center>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_6_3000.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_10_3000.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
		Figure 5: Comparison of DBM FAST algorithm with different eta values (3000 points).
</div>
    <p> </p>
</center>

<h3 id="dbm-fast-analysis">DBM FAST Analysis:</h3>

<p>As can be seen from the images, with the increase of $\eta$, the image also gradually converges from a two-dimensional plane to a one-dimensional line, consistent with the trend of DBM. This indicates that our improved algorithm has not changed the essential difference of the image and greatly accelerated the speed of the algorithm.</p>

<h3 id="comparison-with-dbm">Comparison with DBM</h3>

<p>The following image shows the DBM FAST algorithm with 300 points. They can be better compared with the DBM images(Figure 4).</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_0_300.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_3_300.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
    </div>
    <p> </p>
</center>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_6_300.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/DBM_FAST_10_300.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
		Figure 6: Comparison of DBM FAST algorithm with different eta values (300 points).
</div>
    <p> </p>
</center>

<p>Compared to the DBM image (Figure 4), the two are almost identical.</p>

<p>And the computation time has been significantly reduced.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/time_DBM.png" width="50%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/time_DBM_FAST.png" width="60%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure7: Time Comparison
    </div>
    <p> </p>
</center>

<p>Almost 1000 times faster.</p>

<h3 id="compared-with-dla">Compared with DLA</h3>

<p>Under certain parameter selections, both exhibit tree-like growth.</p>

<p>It can be seen that the DLA algorithm always maintains a larger number of branches and does not gradually converge to one dimension with changes in parameters. The DBM algorithm, as $\eta$ changes, will make the correlation between points more obvious, converging to one dimension and no longer exhibiting branching phenomena.</p>

<h2 id="34-fractal-and-dimensional-features-result">3.4 Fractal and Dimensional Features Result</h2>

<h3 id="sandbox-method-1">Sandbox Method</h3>

<p>​	The experimental results are shown in the following figure</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/Sandbox.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 8: Sandbox Result
    </div>
    <p> </p>
</center>

<p>The experimentally computed slope of the image is
\(D_1=1.6666788360254807\)
which is the fractal dimension.</p>

<p>The fractal dimension result is in the range of 1.6 to 1.7, which is in good agreement with the theory.</p>

<h2 id="23-density-density-correlation-function-method">2.3 Density-Density Correlation Function Method</h2>

<p>The experimental result is shown in the following figure.</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_growth_model/Density.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 9: Density Result
    </div>
    <p> </p>
</center>

<p>​	The slope of the image and the fractal dimension are：
\(k=-\alpha  = -0.35808654164728
\\D_2=d-\alpha=1.64191345835272\)
​	The fractal dimension result is in the range of 1.6 to 1.7, which is in good agreement with the theory.</p>

<h1 id="4-summary">4. Summary</h1>

<ul>
  <li>
    <p>In this experiment, DLA and DBM models were compared and their differences were analyzed.</p>
  </li>
  <li>
    <p>A method to accelerate the Laplace numerical algorithm was proposed and its effectiveness was verified through experiments.</p>
  </li>
  <li>
    <p>During the experiment, a good data structure pattern, “set”, was adopted to improve the program speed.</p>
  </li>
  <li>
    <p>The dimension of DLA was calculated using the sandbox method and the density-density correlation function method. The dimensions obtained by the two methods were both within the range of 1.6 to 1.7, which is close to the theoretical value</p>
  </li>
</ul>

<h1 id="5-reference">5. Reference</h1>

<p>[1] <a href="http://gamma.cs.unc.edu/FRAC/laplacian_large.pdf">laplacian_large</a></p>]]></content><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><category term="Physics" /><summary type="html"><![CDATA[DLA (Diffusion Limited Aggregation) and DBM (The Dielectric Breakdown Model) are two commonly used non-equilibrium growth models. DLA is a classic model for non-equilibrium growth, used to study natural phenomena such as crystal growth, fluid dynamics, and dust aggregation. DBM is a model for dielectric breakdown phenomena. Simulated 2D DLA and DBM patterns, and discussed fractal and dimensional features. Keywords: Random walking, growth model, Laplace Equation, fractals and fractal dimensions.]]></summary></entry><entry><title type="html">Image Warping</title><link href="https://rainzor.github.io/blogs/image-warping" rel="alternate" type="text/html" title="Image Warping" /><published>2022-09-20T00:00:00+00:00</published><updated>2022-09-20T00:00:00+00:00</updated><id>https://rainzor.github.io/blogs/image-warping</id><content type="html" xml:base="https://rainzor.github.io/blogs/image-warping"><![CDATA[<p>Using RBF Method to Realize Image Warpping (<strong>中文</strong>)</p>

<p>If you want to read the source code, please click <a href="https://github.com/Rainzor/USTC_CG_2023s/tree/master/02_image_warping">here</a></p>

<h2 id="1-introduction">1 Introduction</h2>

<p>实现基于径向基函数(RBF)插值方法的图像拖拽变形</p>

<h2 id="2-rbf-algorithm">2 RBF Algorithm</h2>

<blockquote>
  <p>Radial basis functions interpolation method(RBF)</p>
</blockquote>

<p>​	给定 $n$ 对控制点 $(\mathbf{p_i},\mathbf{q _ i})$，$\mathbf{p} _ i,\mathbf{q} _ i\in\mathbb{R}^2$，$i=1,\dots,n$ ，其中 $\mathbf{p_i}$ 是源点，$\mathbf{q _ i}$ 是目标点</p>

<p>​	<strong>插值函数</strong></p>

\[\pmb{f}(\pmb{x})=\sum _ {i=1}^n \boldsymbol{\alpha} _ i R_i(\mathbf{x})+A\mathbf{x}+\mathbf{b}\tag1\]

<p>其中权重系数 $\boldsymbol{\alpha} _ i\in\mathbb{R}^{2}$，$A\in\mathbb{R}^{2\times 2}$，$\mathbf{b}\in\mathbb{R}^2$，径向基函数
\(R_i(\mathbf{x})=\frac{1}{|\mathbf{x-p_i}|^2+d_i}\tag2\)</p>

<p>​	其中 $d$ 是为了防止分母为0的情况出现。</p>

<p>​	在满足插值条件
\(\mathbf{f}(\mathbf{p} _ j)=\sum _ {i=1}^n\boldsymbol{\alpha} _ i R_i(\mathbf{p} _ j)+A\mathbf{p} _ j+\mathbf{b}=\mathbf{q} _ j,\quad j=1,\dots n\tag3\)
上述方程有 $2n+6$ 个自由度，其中 $ \boldsymbol{\alpha} _ i=(\alpha _ i^{(1)},\alpha _  i^{(2)})^T $，按照论文可选的补充约束为
\(A=I,\mathbf{b}=\mathbf{0}\tag4\)
​	所以关于 $\boldsymbol\alpha$ 的方程是
\(\boldsymbol R \boldsymbol\alpha=\boldsymbol q-\boldsymbol p\tag5\)
​	以上线性方程组可以解出权重系数 $\boldsymbol\alpha$，此时根据 $\boldsymbol\alpha$ 的值，结合 <em>eq(4)</em> 代入 <em>eq(1)</em> 即可得到图像中任意点 $\mathbf{x}$ 经过变换后的坐标 $\pmb{f}(\pmb{x})$
\(\pmb{f}(\pmb{x})=\sum _ {i=1}^n \boldsymbol{\alpha} _ i R _ i(\mathbf{x})+\pmb{x}\tag6\)
​	最终只要把源图像中 $\mathbf{x}$ 处的像素值代入 $\pmb{f}(\pmb{x})$ 处即可</p>

<h2 id="3-experiment">3 Experiment</h2>

<p>原图如下</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/MonaLisa.jpg" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 1:MonaLisa
    </div>
    <p> </p>
</center>

<h3 id="31-normal-warping">3.1 Normal Warping</h3>

<p>​	在实验过程中，为了采用恰当的 $d$ 值，不妨取 d 为所有拖动距离的平方和</p>

<p>\(d=\sum_i^n\Vert\mathbf{q_i}-\mathbf{p} _ i\Vert^2/n\tag7\)
​	得到结果：</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/normal.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 2:Normal Warping
    </div>
    <p> </p>
</center>

<p>在该结果中可以看出，RBF Image Warping 方法得到的图像可能出现大量缝隙，但在插值之后仍然可以得到伸缩的结果图像</p>

<h3 id="32-interpolation">3.2 Interpolation</h3>

<p>​	之所以会出现缝隙现象，是因为在实验中计算 $\pmb{f}(\pmb{x})$ 值的过程中，为了给像素点位置赋值，必须强行要求取整 $round( \pmb{f}(\pmb{x}) )$ ，所以导致有些像素点的位置在给图像赋值的过程中没有渠道。</p>

<p>​	采取的解决办法是要对缝隙中的点进行插值。这里使用平均值插值的方法，具体实现时在对目标图像着色时记录被着色的像素点，最后再对于未着色的点，取其像素值为周边八个点中已着色点的均值。得到以下结果</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/Interpolation.png" width="30%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 3:Interpolation warping
    </div>
    <p> </p>
</center>

<p>但是当图形扭曲程度较大时，周围9个点可能无法弥补所有的像素,或许需要更多的周围点做平均，这又会使得图形较为模糊。</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/before_inter.png" width="20%" />
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/after_inter.png" width="20%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 4:左：插值前；右：插值后
    </div>
    <p> </p>
</center>

<p>​	由图可见修补了缝隙。</p>

<h3 id="33-rbf-reverse-method">3.3 RBF Reverse Method</h3>

<p>​	为了解决上面出现的裂缝问题，另一种处理思路是，把 $\mathbf{p_i}$当作是目标点，而 $\mathbf{q _ i}$ 是源点，要做的</p>

<p>是以对预期变换后图像的每个像素点位置找到它对应的原位置，那么此时方程变为
\(\begin{aligned}
R_i(\mathbf{x})&amp;=\frac{1}{|\mathbf{x-q_i}|^2+d_i}\\
\boldsymbol R \boldsymbol\alpha&amp;=\mathbf p-\mathbf q\\
\pmb{f}(\pmb{x})&amp;=\sum _ {i=1}^n \boldsymbol{\alpha} _ i R_i(\mathbf{x})+\pmb{x}
\end{aligned}\tag8\)
此时要做的是计算出每个像素点 $\mathbf{x}=(i,j)$ 对应的原位置 $\mathbf {f(x)}$，此时变换后新图像每点的像素值为 $\mathbf{f(x)}$ 处的像素值。</p>

<p>另外，通过阅读文献<a href="#refer-anchor-1"><sup>1</sup></a>，尝试了另一种 $d$ 的定义，它是对每个 $R_i(x)$ 都赋予不同的值，为距离 $\mathbf q_i$最近的其他源点的距离平方值，如果只有一组点，则简单定义 $\mathbf q$ 与 $\mathbf p$ 的距离平方和 <em>eq (7)</em>保持一致</p>

\[d_i=\min_{j\ne i}\Vert\mathbf{q}_j-\mathbf{q} _ i\Vert^2\quad(n&gt;1)\\
d = \Vert\mathbf{p}-\mathbf{q}\Vert\quad(n=1)\]

<p>这种定义会导致变形在真正的”目标数据点“ $\mathbf{q  _ i}$ 之间距较大的地方更柔和，而在”目标数据点”  $\mathbf{q  _ i}$ 靠得更近的地方图像形变效果更强</p>

<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/wide_space.png" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
		Figure 5:Reverse RBF: widely spaced
    </div>
    <p> </p>
</center>
<center>
    <img style="
        border-radius: 0.3125em;
        box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);" src="/images/img_image_warping/close_space.png" width="40%" />
    <br />
    <div style="
        color: orange;
        border-bottom: 1px solid #d9d9d9;
        display: inline-block;
        color: #999;
        padding: 2px;">
        Figure 6:Reverse RBF: closely spaced
    </div>
    <p> </p>
</center>

<h2 id="4-summary">4 Summary</h2>

<ul>
  <li>
    <p>本次实验学习了如何矢量化处理图形，并通过插值方法对图形进行变形</p>
  </li>
  <li>
    <p>在实验中发现了图像缝隙的问题，并找到了两种解决办法：周围像素插值和RBW逆运算，加深了对图形学中图形像素光栅化的认识</p>
  </li>
</ul>

<h2 id="5-reference">5 Reference</h2>

<p>[1] <a href="https://www.semanticscholar.org/paper/Image-Warping-with-Scattered-Data-Interpolation-Ruprecht-M%C3%BCller/5a9e2604064d08f2a8b7dcef4cd4e9a2ce2a88c2?p2df">Image Warping with Scattered Data Interpolation Methods</a></p>]]></content><author><name>Runze Wang</name><email>runzewang@mail.ustc.edu.cn</email></author><category term="Computer Graphics" /><summary type="html"><![CDATA[实现基于径向基函数(RBF)插值方法的图像拖拽变形。Using Radial Basis Function (RBF) interpolation method for image warping.]]></summary></entry></feed>