背景
传统SGM算法效果虽好,但严重依赖于使用者的调参经验,算法中的惩罚因子对算法的性能有极大的影响,为此提出使用CNN学习的方式来进行参数估计;SGM-Net的输入为小图像patch以及位置,输出为3D物体结构的惩罚参数;为了训练网络,提出了一种使用稀疏标注视差的损失函数;此外,还提出了一种新的SGM参数化方式,根据正负视差变化来调整惩罚参数,以便于区分不同的对象结构;
网络结构
SGM
对于经典传统算法中的SGM,其能量函数如式1所示:
E
(
D
)
=
∑
x
(
C
(
x
,
d
x
)
+
∑
y
∈
N
x
P
1
T
[
∣
d
x
−
d
y
∣
=
1
]
+
∑
y
∈
N
x
P
2
T
[
∣
d
x
−
d
y
∣
>
1
]
)
(1)
E(D)=\sum_{x}(C(x,d^{x})+\sum_{y\in N_{x}}P_1T[|d^x-d^y|=1]+\sum_{y\in N_{x}}P_2T[|d^x-d^y|>1])\tag1
E(D)=x∑(C(x,dx)+y∈Nx∑P1T[∣dx−dy∣=1]+y∈Nx∑P2T[∣dx−dy∣>1])(1)
其中
C
(
x
,
d
x
)
C(x,d^{x})
C(x,dx)表示在像素
x
=
(
u
,
v
)
x=(u,v)
x=(u,v) 点,视差为
d
x
d^x
dx 时的代价,
P
1
P_1
P1 是对
p
p
p 的邻域内处于同一个平面上的视差点给予小惩罚;
P
2
P_2
P2 是对邻域内不连续的视差给予大惩罚,第一项为数据项:体现总体的匹配代价,后两项为平滑项:使得图像尽量平滑;
L
r
(
x
0
,
d
)
=
C
(
x
0
,
d
)
+
min
{
L
r
′
(
x
0
−
r
,
d
)
L
r
′
(
x
0
−
r
,
d
−
1
)
+
P
1
L
r
′
(
x
0
−
r
,
d
+
1
)
+
P
1
min
i
L
r
′
(
x
0
−
r
,
i
)
+
P
2
}
−
min
i
L
r
′
(
x
0
−
r
,
i
)
(2)
L_{r}(\mathrm{x_0}, d)=\mathrm{C}(\mathrm{x_0}, d)+\min \left\{\begin{array}{l} L^\prime_{r}(\mathrm{x_0}-\mathrm{r}, d) \\ L^\prime_{r}(\mathrm{x_0}-\mathrm{r}, d-1)+P_{1} \\ L^\prime_{r}(\mathrm{x_0}-\mathrm{r}, d+1)+P_{1} \\ \underset{i}{\min} L^\prime_{r}(\mathrm{x_0}-\mathrm{r}, i)+P_{2} \end{array}\right\}-\min _{i} L^\prime_{r}(\mathrm{x_0}-\mathrm{r}, i)\tag2
Lr(x0,d)=C(x0,d)+min⎩
⎨
⎧Lr′(x0−r,d)Lr′(x0−r,d−1)+P1Lr′(x0−r,d+1)+P1iminLr′(x0−r,i)+P2⎭
⎬
⎫−iminLr′(x0−r,i)(2)
最后基于WTA计算最终的视差图如式3所示:
D
(
x
0
)
=
a
r
g
min
d
∑
r
L
r
(
x
0
,
d
)
(3)
D(x_0)=arg\min_{d}\sum_rL_r(x_0,d)\tag3
D(x0)=argdminr∑Lr(x0,d)(3)
对于SGM的详细介绍请移步博主的另外一篇博客:https://blog.csdn.net/weixin_40957452/article/details/121524482
SGM-Net
SGM-Net分为两个阶段:在训练阶段通过最小化路径损失与邻域损失来为每个像素预测 P 1 P_1 P1 与 P 2 P_2 P2 惩罚因子; 在测试阶段,SGM使用SGM-Net预测的结果进行视差估计,得到最后的视差图;
标准参数化
上图表示SGM算法中沿路径进行代价聚合的过程,从左往右是沿着路径上的像素点,从上往下是路径上的每个像素的视差与最优视差选择;虚线指向正确视差,橙线与蓝线表示两种视差聚合路径,从中可以看出橙线与紫线在
x
2
x_2
x2 后面开始分离,如式2所示,在求
x
1
x_1
x1 点的代价时,取
d
1
x
1
d_1^{x_1}
d1x1加上
P
2
P_2
P2 惩罚的代价(式2中min大括号内中的第4项)与取
d
4
x
1
d_4^{x_1}
d4x1加上
P
1
P_1
P1惩罚的代价(式2中min大括号内中的第3项)的值相等,则此时取哪一项具有不确定性,表明SGM算法中沿路径聚合具有模糊性;
路径损失
在
x
0
x_0
x0 像素处,沿着深度范围考虑,应该满足在深度
d
g
t
x
0
d_{gt}^{\mathbf{x}_0}
dgtx0 的代价值小于其余深度的代价值
d
i
x
0
d_{i}^{\mathbf{x}_{0}}
dix0 也就有:
L
r
(
x
0
,
d
i
x
0
)
>
L
r
(
x
0
,
d
g
t
x
0
)
L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{i}^{\mathbf{x}_{0}}\right)>L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)
Lr(x0,dix0)>Lr(x0,dgtx0) ,将其写成Hinge loss形式如式4所示:
E
g
=
∑
d
i
x
0
≠
d
g
t
x
0
max
(
0
,
L
r
(
x
0
,
d
g
t
x
0
)
−
L
r
(
x
0
,
d
i
x
0
)
+
m
)
(4)
E_{g}=\sum_{d_{i}^{\mathbf{x}_{0}} \neq d_{g t}^{\mathbf{x}_{0}}} \max \left(0, L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)-L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{i}^{\mathbf{x}_{0}}\right)+m\right)\tag4
Eg=dix0=dgtx0∑max(0,Lr(x0,dgtx0)−Lr(x0,dix0)+m)(4)
式4表示如果
d
g
t
x
0
d_{gt}^{\mathbf{x}_0}
dgtx0 与
d
i
x
0
d_{i}^{\mathbf{x}_{0}}
dix0 的距离若大于m则损失为0,否则损失为
m
−
[
L
r
(
x
0
,
d
i
x
0
)
−
L
r
(
x
0
,
d
g
t
x
0
)
]
m - [L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{i}^{\mathbf{x}_{0}}\right)-L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)]
m−[Lr(x0,dix0)−Lr(x0,dgtx0)] ,
x
0
x_0
x0 点的损失在路径上聚合而来,如式5所示:
L
(
x
0
,
d
g
t
x
0
)
=
c
(
x
0
,
d
g
t
x
0
)
+
c
(
x
1
,
d
1
x
1
)
+
c
(
x
2
,
d
3
x
2
)
+
c
(
x
3
,
d
3
x
3
)
+
P
2
(
x
2
)
−
β
L
(
x
0
,
d
5
x
0
)
=
c
(
x
0
,
d
5
x
0
)
+
c
(
x
1
,
d
4
x
1
)
+
c
(
x
2
,
d
3
x
2
)
+
c
(
x
3
,
d
3
x
3
)
+
P
1
(
x
1
)
+
P
1
(
x
2
)
−
β
(5)
\begin{aligned} L\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right) &=c\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)+c\left(\mathbf{x}_{1}, d_{1}^{\mathbf{x}_{1}}\right)+c\left(\mathbf{x}_{2}, d_{3}^{\mathbf{x}_{2}}\right) \\ &+c\left(\mathbf{x}_{3}, d_{3}^{\mathbf{x}_{3}}\right)+P_{2}\left(\mathbf{x}_{2}\right)-\beta \\\\ L\left(\mathbf{x}_{0}, d_{5}^{\mathbf{x}_{0}}\right) &=c\left(\mathbf{x}_{0}, d_{5}^{\mathbf{x}_{0}}\right)+c\left(\mathbf{x}_{1}, d_{4}^{\mathbf{x}_{1}}\right)+c\left(\mathbf{x}_{2}, d_{3}^{\mathbf{x}_{2}}\right) \\ &+c\left(\mathbf{x}_{3}, d_{3}^{\mathbf{x}_{3}}\right)+P_{1}\left(\mathbf{x}_{1}\right)+P_{1}\left(\mathbf{x}_{2}\right)-\beta \end{aligned}\tag5
L(x0,dgtx0)L(x0,d5x0)=c(x0,dgtx0)+c(x1,d1x1)+c(x2,d3x2)+c(x3,d3x3)+P2(x2)−β=c(x0,d5x0)+c(x1,d4x1)+c(x2,d3x2)+c(x3,d3x3)+P1(x1)+P1(x2)−β(5)
其中
L
(
x
0
,
d
g
t
x
0
)
L\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)
L(x0,dgtx0) 表示黄线的聚合路径,
L
(
x
0
,
d
5
x
0
)
L\left(\mathbf{x}_{0}, d_{5}^{\mathbf{x}_{0}}\right)
L(x0,d5x0) 代表紫线的聚合路径;
β
\beta
β 代表式2中的最小的路径损失。由此,路径累积损失可以表示为式6形式:
L
r
(
x
0
,
d
i
x
0
)
=
γ
+
∑
n
(
P
1
,
r
(
x
n
)
T
[
∣
δ
d
x
n
←
d
i
x
0
∣
=
1
]
+
P
2
,
r
(
x
n
)
T
[
∣
δ
d
x
n
←
d
i
x
0
∣
>
1
]
)
(6)
\begin{array}{r} L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{i}^{\mathbf{x}_{0}}\right)=\gamma+\sum_{n}\left(P_{1, \mathbf{r}}\left(\mathbf{x}_{n}\right) T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{i}^{\mathbf{x}_{0}}}\right|=1\right]\right. \left.+P_{2, \mathbf{r}}\left(\mathbf{x}_{n}\right) T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{i}^{\mathbf{x}_{0}}}\right|>1\right]\right) \end{array}\tag6
Lr(x0,dix0)=γ+∑n(P1,r(xn)T[
δdxn←dix0
=1]+P2,r(xn)T[
δdxn←dix0
>1])(6)
其中:
T
[
∣
δ
d
x
n
←
d
i
x
0
∣
>
1
]
T[|\delta d^{\mathbf{x}_{n} \leftarrow d_{i}^{\mathbf{x}_{0}}}|>1]
T[∣δdxn←dix0∣>1] 表示在
d
i
x
0
d_i^{x_0}
dix0 聚合路径上,相邻像素间的视差取值大于1的点,如橙线
x
2
x_2
x2到
x
1
x_1
x1 过程中,
x
2
x_2
x2点的取值为
d
3
d_3
d3,
x
1
x_1
x1点的取值为
d
1
d_1
d1,相邻像素间的取值差值为2,此时
T
T
T取值为1;且给予
P
2
P_2
P2 惩罚;
γ
\gamma
γ 表示聚合路径上累积匹配代价(不含每个像素上的最小代价),且
γ
\gamma
γ 与
P
1
与
P
2
P_1 与 P_2
P1与P2 无关;将式6代入式4中得到损失函数
E
g
E_g
Eg,再对
P
1
P_1
P1 与
P
2
P_2
P2 求偏导得:
∂
E
g
∂
P
1
,
r
=
∑
d
t
x
0
≠
d
g
t
x
0
∑
n
(
T
[
∣
δ
d
x
n
←
d
g
t
x
0
∣
=
1
]
−
T
[
∣
δ
d
x
n
←
d
t
x
0
∣
=
1
]
)
∂
E
g
∂
P
2
,
r
=
∑
d
t
x
0
≠
d
g
t
x
0
∑
n
(
T
[
∣
δ
d
x
n
←
d
g
t
x
0
∣
>
1
]
−
T
[
∣
δ
d
x
n
←
d
t
x
0
∣
>
1
]
)
(7)
\begin{array}{l} \frac{\partial E_{g}}{\partial P_{1, \mathbf{r}}}=\sum_{d_{t}^{\mathbf{x}_{0}} \neq d_{g t}^{\mathbf{x}_{0}} }\sum_n\left(T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{g t}^{\mathbf{x}_{0}}}\right|=1\right]-T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{t}^{\mathbf{x}_{0}}}\right|=1\right]\right)\\\\ \frac{\partial E_{g}}{\partial P_{2, \mathbf{r}}}=\sum_{d_{t}^{\mathbf{x}_{0}} \neq d_{g t}^{\mathbf{x}_{0}}} \sum_{n}\left(T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{g t}^{\mathbf{x}_{0}}}\right|>1\right]-T\left[\left|\delta d^{\mathbf{x}_{n} \leftarrow d_{t}^{\mathbf{x}_{0}}}\right|>1\right]\right) \end{array}\tag7
∂P1,r∂Eg=∑dtx0=dgtx0∑n(T[
δdxn←dgtx0
=1]−T[
δdxn←dtx0
=1])∂P2,r∂Eg=∑dtx0=dgtx0∑n(T[
δdxn←dgtx0
>1]−T[
δdxn←dtx0
>1])(7)
例如:将式5代入式4中求偏导得:
∂
E
g
∂
P
1
(
x
1
)
=
−
1
,
∂
E
g
∂
P
2
(
x
1
)
=
0
,
∂
E
g
∂
P
2
(
x
2
)
=
1
,
when
E
g
=
L
r
(
x
0
,
d
g
t
x
0
)
−
L
r
(
x
0
,
d
5
x
0
)
+
m
>
0
(8)
\begin{array}{r} \frac{\partial E_{g}}{\partial P_{1}\left(\mathrm{x}_{1}\right)}=-1, \frac{\partial E_{g}}{\partial P_{2}\left(\mathrm{x}_{1}\right)}=0, \frac{\partial E_{g}}{\partial P_{2}\left(\mathrm{x}_{2}\right)}=1, \\\\ \text { when } E_{g}=L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{g t}^{\mathbf{x}_{0}}\right)-L_{\mathbf{r}}\left(\mathbf{x}_{0}, d_{5}^{\mathbf{x}_{0}}\right)+m>0 \end{array}\tag8
∂P1(x1)∂Eg=−1,∂P2(x1)∂Eg=0,∂P2(x2)∂Eg=1, when Eg=Lr(x0,dgtx0)−Lr(x0,d5x0)+m>0(8)
有了上述的分析,就可以使用标准的神经网络来对其训练;
邻域损失
由上述的分析可知:沿路径的聚合具有模糊性,为此引入邻域损失函数来降低这种不确定性;其核心思想为正确的代价聚合路径应该包含正确的视差信息且长度最短,如下图所示:
图中,红线为正确的路径,绿线为错误的路径,图a表示边缘区域,相邻像素的视差变化较大;图b为倾斜区域,相邻像素间的视差变化小,图c为平坦区域,相邻像素的视差相同;三幅图中红线所计算的损失
F
b
(
.
)
,
F
s
(
.
)
,
F
f
(
.
)
F_b(.),F_s(.),F_f(.)
Fb(.),Fs(.),Ff(.) 小于绿线的损失
N
(
.
)
N(.)
N(.);邻域损失如式9所示:
E
n
X
=
∑
d
≠
d
g
t
x
1
max
(
0
,
F
X
(
x
1
,
d
g
t
x
1
)
−
N
(
x
1
,
d
g
t
x
0
,
d
)
+
m
)
(9)
E_{n_{X}}=\sum_{d \neq d_{g t}^{\mathbf{x}_{1}}} \max \left(0, F_{X}\left(\mathbf{x}_{1}, d_{g t}^{\mathbf{x}_{1}}\right)-N\left(\mathbf{x}_{1}, d_{g t}^{\mathbf{x}_{0}}, d\right)+m\right)\tag9
EnX=d=dgtx1∑max(0,FX(x1,dgtx1)−N(x1,dgtx0,d)+m)(9)
其中,
N
(
.
)
N(.)
N(.)如式10所示:
N
(
x
1
,
d
g
t
x
0
,
d
)
=
L
r
(
x
1
,
d
)
+
P
1
,
r
(
x
1
)
T
[
∣
d
g
t
x
0
−
d
∣
=
1
]
+
P
2
,
r
(
x
1
)
T
[
∣
d
g
t
x
0
−
d
∣
>
1
]
(10)
\begin{aligned} N\left(\mathbf{x}_{1}, d_{g t}^{\mathrm{x}_{0}}, d\right)=L_{\mathbf{r}}\left(\mathbf{x}_{1}, d\right) &+P_{1, \mathbf{r}}\left(\mathbf{x}_{1}\right) T\left[\left|d_{g t}^{\mathbf{x}_{0}}-d\right|=1\right] +P_{2, \mathbf{r}}\left(\mathbf{x}_{1}\right) T\left[\left|d_{g t}^{\mathbf{x}_{0}}-d\right|>1\right] \end{aligned}\tag{10}
N(x1,dgtx0,d)=Lr(x1,d)+P1,r(x1)T[
dgtx0−d
=1]+P2,r(x1)T[
dgtx0−d
>1](10)
其中
F
X
(
.
)
F_X(.)
FX(.) 表示相邻像素之间的视差变化,
F
b
(
.
)
表示边缘损失
,
F
s
(
.
)
表示倾斜表面损失
,
F
f
(
.
)
表示平坦平面损失
F_b(.)表示边缘损失,F_s(.)表示倾斜表面损失,F_f(.)表示平坦平面损失
Fb(.)表示边缘损失,Fs(.)表示倾斜表面损失,Ff(.)表示平坦平面损失;
边缘损失Border:
F
b
(
x
1
,
d
g
t
x
1
)
=
L
r
(
x
1
,
d
g
t
x
1
)
+
P
2
,
r
(
x
1
)
(11)
F_{b}\left(\mathbf{x}_{1}, d_{g t}^{\mathrm{x}_{1}}\right)=L_{\mathbf{r}}\left(\mathbf{x}_{1}, d_{g t}^{\mathrm{x}_{1}}\right)+P_{2, \mathbf{r}}\left(\mathbf{x}_{1}\right)\tag{11}
Fb(x1,dgtx1)=Lr(x1,dgtx1)+P2,r(x1)(11)
倾斜面损失:
F
s
(
x
1
,
d
g
t
x
1
)
=
L
r
(
x
1
,
d
g
t
x
1
)
+
P
1
,
r
(
x
1
)
(12)
F_{s}\left(\mathbf{x}_{1}, d_{g t}^{\mathrm{x}_{1}}\right)=L_{\mathbf{r}}\left(\mathbf{x}_{1}, d_{g t}^{\mathbf{x}_{1}}\right)+P_{1, \mathbf{r}}\left(\mathbf{x}_{1}\right) \tag{12}
Fs(x1,dgtx1)=Lr(x1,dgtx1)+P1,r(x1)(12)
平坦面损失:
F
f
(
x
1
,
d
g
t
x
1
)
=
L
r
(
x
1
,
d
g
t
x
1
)
(13)
F_{f}\left(\mathbf{x}_{1}, d_{g t}^{\mathbf{x}_{1}}\right)=L_{\mathbf{r}}\left(\mathbf{x}_{1}, d_{g t}^{\mathbf{x}_{1}}\right)\tag{13}
Ff(x1,dgtx1)=Lr(x1,dgtx1)(13)
公式9像前文介绍一样,是可微的;
使用了不同损失的效果如图5所示:使用了邻域损失可以使得图像更加清晰,但是会增加许多噪点,将路径损失与邻域损失结合使用会取得较不错的效果,总的损失函数如式14所示:
E
=
∑
r
∈
R
(
∑
x
1
,
x
0
∈
G
b
E
n
b
+
∑
x
1
,
x
0
∈
G
s
E
n
s
+
∑
x
1
,
x
0
∈
G
f
E
n
f
+
ξ
∑
x
0
∈
G
E
g
)
(14)
E=\sum_{\mathbf{r} \in R}\left(\sum_{\mathbf{x}_{1}, \mathbf{x}_{0} \in G_{b}} E_{n_{b}}+\sum_{\mathbf{x}_{1}, \mathbf{x}_{0} \in G_{s}} E_{n_{s}}+\sum_{\mathbf{x}_{1}, \mathbf{x}_{0} \in G_{f}} E_{n_{f}}+\xi \sum_{\mathbf{x}_{0} \in G} E_{g}\right)\tag{14}
E=r∈R∑
x1,x0∈Gb∑Enb+x1,x0∈Gs∑Ens+x1,x0∈Gf∑Enf+ξx0∈G∑Eg
(14)
其中
ξ
\xi
ξ 为权重参数,在各个
r
r
r 方向上随机选择相同数量的border、slant、flat处的像素点;其中flat处像素点
x
1
x_1
x1 与
x
0
x_0
x0 的视差值相同,slant处
x
1
x_1
x1 与
x
0
x_0
x0 的视差值相差1(+1或-1),boder处
x
1
x_1
x1 与
x
0
x_0
x0 的视差值相差大于1,在多个视差候选中随机选择一个;
有向参数化
由于在前面的讨论中,相邻像素最优视差相差大于1,则给
P
2
P_2
P2 惩罚,相邻像素最优视差相差等于1,给
P
1
P_1
P1 惩罚,在这里,为了增强模型的表达能力,同时视差的差值的正负:
- 当 x 1 d − x 0 d = 1 x_1^d-x_0^d=1 x1d−x0d=1 时惩罚为 P 1 + P_1^+ P1+
- 当 x 1 d − x 0 d = − 1 x_1^d-x_0^d=-1 x1d−x0d=−1 时惩罚为 P 1 − P_1^- P1−
- 当 x 1 d − x 0 d > 1 x_1^d-x_0^d>1 x1d−x0d>1 时惩罚为 P 2 + P_2^+ P2+
- 当 x 1 d − x 0 d < − 1 x_1^d-x_0^d<-1 x1d−x0d<−1 时惩罚为 P 2 − P_2^- P2−
L
r
′
±
(
x
0
,
d
)
=
c
(
x
0
,
d
)
+
m
i
n
{
L
r
′
±
(
x
1
,
d
)
min
i
=
d
±
1
L
r
′
(
x
1
,
i
)
+
P
1
,
r
+
T
[
d
−
i
=
1
]
⏟
T
1
+
[
⋅
]
+
P
1
−
T
[
i
−
d
=
1
]
⏟
T
1
−
[
⋅
]
min
i
≠
d
±
1
L
r
′
±
(
x
1
,
i
)
+
P
2
,
r
+
T
[
i
<
d
]
⏟
T
2
+
[
⋅
]
+
P
2
,
r
−
T
[
i
>
d
]
⏟
T
2
−
[
⋅
]
)
}
(15)
L_{\mathbf{r}}^{\prime \pm}\left(\mathbf{x}_{0}, d\right)=c\left(\mathbf{x}_{0}, d\right)+min\begin{Bmatrix} L_{\mathbf{r}}^{\prime \pm}(\mathbf{x}_{1}, d)\\\\ \min _{i=d \pm 1} L_{\mathbf{r}}^{\prime}\left(\mathbf{x}_{1}, i\right)+P_{1, \mathbf{r}}^{+} \underbrace{T[d-i=1]}_{T_{1}^{+}[\cdot]}+P_{1}^{-} \underbrace{T[i-d=1]}_{T_{1}^{-}[\cdot]}\\\\ \min _{i \neq d \pm 1} L_{\mathbf{r}}^{\prime \pm}\left(\mathbf{x}_{1}, i\right)+P_{2, \mathbf{r}}^{+} \underbrace{T[i<d]}_{T_{2}^{+}[\cdot]}+P_{2, \mathbf{r}}^{-} \underbrace{T[i>d]}_{T_{2}^{-}[\cdot]}) \end{Bmatrix}\tag{15}
Lr′±(x0,d)=c(x0,d)+min⎩
⎨
⎧Lr′±(x1,d)mini=d±1Lr′(x1,i)+P1,r+T1+[⋅]
T[d−i=1]+P1−T1−[⋅]
T[i−d=1]mini=d±1Lr′±(x1,i)+P2,r+T2+[⋅]
T[i<d]+P2,r−T2−[⋅]
T[i>d])⎭
⎬
⎫(15)
增加了有向参数化后:
将式6中的
L
r
±
L_r^\pm
Lr± 替换
L
r
L_r
Lr得:
L
r
±
=
γ
+
∑
n
(
P
1
,
r
+
T
1
+
[
⋅
]
+
P
1
,
r
−
T
1
−
[
⋅
]
+
P
2
,
r
+
T
2
+
[
⋅
]
+
P
2
,
r
−
T
2
−
[
⋅
]
)
(16)
L_{\mathbf{r}}^{\pm}=\gamma+\sum_{n}\left(P_{1, \mathbf{r}}^{+} T_{1}^{+}[\cdot]+P_{1, \mathbf{r}}^{-} T_{1}^{-}[\cdot]+P_{2, \mathbf{r}}^{+} T_{2}^{+}[\cdot]+P_{2, \mathbf{r}}^{-} T_{2}^{-}[\cdot]\right)\tag{16}
Lr±=γ+n∑(P1,r+T1+[⋅]+P1,r−T1−[⋅]+P2,r+T2+[⋅]+P2,r−T2−[⋅])(16)
式10更新后得:
N
±
(
x
1
,
d
g
t
x
0
,
d
)
=
L
r
±
(
x
1
,
d
)
+
P
1
,
r
+
(
x
1
)
T
[
δ
=
1
]
+
P
1
,
r
−
(
x
1
)
T
[
δ
=
−
1
]
+
P
2
,
r
+
(
x
1
)
T
[
δ
>
1
]
+
P
2
,
r
−
(
x
1
)
T
[
δ
<
−
1
]
(17)
\begin{aligned} N^{\pm}\left(\mathrm{x}_{1}, d_{g t}^{\mathbf{x}_{0}}, d\right) &=L_{\mathbf{r}}^{\pm}\left(\mathrm{x}_{1}, d\right) +P_{1, \mathbf{r}}^{+}\left(\mathrm{x}_{1}\right) T[\delta=1]+P_{1, \mathbf{r}}^{-}\left(\mathrm{x}_{1}\right) T[\delta=-1] +P_{2, \mathbf{r}}^{+}\left(\mathrm{x}_{1}\right) T[\delta>1]+P_{2, \mathbf{r}}^{-}\left(\mathrm{x}_{1}\right) T[\delta<-1] \end{aligned}\tag{17}
N±(x1,dgtx0,d)=Lr±(x1,d)+P1,r+(x1)T[δ=1]+P1,r−(x1)T[δ=−1]+P2,r+(x1)T[δ>1]+P2,r−(x1)T[δ<−1](17)
其中
δ
=
d
g
t
x
0
−
d
\delta=d_{g t}^{\mathrm{x}_{0}}-d
δ=dgtx0−d,
F
b
F_b
Fb 更新后为如式18所示:
F
b
±
(
x
1
,
d
g
t
x
)
=
L
r
(
x
1
,
d
g
t
x
1
)
+
P
2
,
r
+
(
x
1
)
T
[
d
g
t
x
0
>
d
g
t
x
1
]
+
P
2
,
r
−
(
x
1
)
T
[
d
g
t
x
0
<
d
g
t
x
1
]
(18)
\begin{aligned} F_{b}^{\pm}\left(\mathrm{x}_{1}, d_{g t}^{\mathrm{x}}\right)=L_{\mathbf{r}}\left(\mathrm{x}_{1}, d_{g t}^{\mathrm{x}_{1}}\right) +P_{2, \mathbf{r}}^{+}\left(\mathrm{x}_{1}\right) T\left[d_{g t}^{\mathrm{x}_{0}}>d_{g t}^{\mathrm{x}_{1}}\right] +P_{2, \mathbf{r}}^{-}\left(\mathrm{x}_{1}\right) T\left[d_{g t}^{\mathrm{x}_{0}}<d_{g t}^{\mathrm{x}_{1}}\right] \end{aligned}\tag{18}
Fb±(x1,dgtx)=Lr(x1,dgtx1)+P2,r+(x1)T[dgtx0>dgtx1]+P2,r−(x1)T[dgtx0<dgtx1](18)
F
s
F_s
Fs 更新后为如式19所示:
F
s
±
(
x
1
,
d
g
t
x
)
=
L
r
(
x
1
,
d
g
t
x
1
)
+
P
1
,
r
+
(
x
1
)
T
[
d
g
t
x
0
−
d
g
t
x
1
=
1
]
+
P
1
,
r
−
(
x
1
)
T
[
d
g
t
x
1
−
d
g
t
x
0
=
1
]
(19)
\begin{aligned} F_{s}^{\pm}\left(\mathrm{x}_{1}, d_{g t}^{\mathrm{x}}\right)=L_{\mathbf{r}}\left(\mathrm{x}_{1}, d_{g t}^{\mathrm{x}_{1}}\right) +P_{1, \mathbf{r}}^{+}\left(\mathbf{x}_{1}\right) T\left[d_{g t}^{\mathrm{x}_{0}}-d_{g t}^{\mathrm{x}_{1}}=1\right] +P_{1, \mathbf{r}}^{-}\left(\mathbf{x}_{1}\right) T\left[d_{g t}^{\mathrm{x}_{1}}-d_{g t}^{\mathrm{x}_{0}}=1\right] \end{aligned}\tag{19}
Fs±(x1,dgtx)=Lr(x1,dgtx1)+P1,r+(x1)T[dgtx0−dgtx1=1]+P1,r−(x1)T[dgtx1−dgtx0=1](19)
SGM-Net模型结构
模型输入为图像patch与归一化后的位置参数,通过最小化损失函数来优化惩罚参数,在模型中国使用ELU来保证输出的惩罚因子为正。代价聚合时使用四路径聚合,模型的输出为
8
(
=
2
[
P
1
,
P
2
]
×
4
[
d
i
r
e
c
t
i
o
n
]
)
8(=2[P_1,P_2]\times 4[direction])
8(=2[P1,P2]×4[direction]),代表了上图8个惩罚因子;
实验结果