Horn-Schunck method is a global method which introduces a global constraint of smoothness to solve the aperture problem in Optical Flow.
The flow is formulated as a global energy functional which is then sought to be minimized.
E
(
u
,
v
)
=
∫
∫
[
(
I
x
u
+
I
y
v
+
I
t
)
2
+
α
2
(
∣
∣
∇
u
∣
∣
2
+
∣
∣
∇
v
∣
∣
2
)
]
d
x
d
y
E(u,v) = \int \int [(I_x u + I_yv + I_t)^2 + \alpha^2(||\nabla u||^2 + ||\nabla v||^2)] dx dy
E(u,v)=∫∫[(Ixu+Iyv+It)2+α2(∣∣∇u∣∣2+∣∣∇v∣∣2)]dxdy
Because
[
u
v
]
=
f
(
[
x
y
]
)
\begin{bmatrix} u \\ v \\ \end{bmatrix} = f(\begin{bmatrix} x \\ y \\ \end{bmatrix})
[uv]=f([xy])
By multi-dimensional Euler-Lagrange equation:
∂
L
∂
u
−
∂
∂
x
∂
L
∂
u
x
−
∂
∂
y
∂
L
∂
u
y
=
0
\frac{\partial L}{\partial u} - \frac{\partial}{\partial x} \frac{\partial L}{\partial u_x} - \frac{\partial}{\partial y} \frac{\partial L}{\partial u_y} = 0
∂u∂L−∂x∂∂ux∂L−∂y∂∂uy∂L=0
∂ L ∂ v − ∂ ∂ x ∂ L ∂ v x − ∂ ∂ y ∂ L ∂ v y = 0 \frac{\partial L}{\partial v} - \frac{\partial}{\partial x} \frac{\partial L}{\partial v_x} - \frac{\partial}{\partial y} \frac{\partial L}{\partial v_y} = 0 ∂v∂L−∂x∂∂vx∂L−∂y∂∂vy∂L=0
Because
L
=
(
I
x
u
+
I
y
v
+
I
t
)
2
+
α
2
(
u
x
2
+
u
y
2
+
v
x
2
+
v
y
2
)
d
x
d
y
L = (I_x u + I_y v + I_t)^2 + \alpha^2(u_x^2 + u_y^2 + v_x^2 + v_y^2) dx dy
L=(Ixu+Iyv+It)2+α2(ux2+uy2+vx2+vy2)dxdy
So we then have
I
x
(
I
x
u
+
I
y
v
+
I
t
)
−
α
2
(
∂
u
x
∂
x
+
∂
u
y
∂
x
)
=
0
I_x(I_x u + I_y v + I_t) - \alpha^2(\frac{\partial u_x}{\partial x} + \frac{\partial u_y}{\partial x}) = 0
Ix(Ixu+Iyv+It)−α2(∂x∂ux+∂x∂uy)=0
I y ( I x u + I y v + I t ) − α 2 ( ∂ v x ∂ x + ∂ v y ∂ x ) = 0 I_y(I_x u + I_y v + I_t) - \alpha^2(\frac{\partial v_x}{\partial x} + \frac{\partial v_y}{\partial x}) = 0 Iy(Ixu+Iyv+It)−α2(∂x∂vx+∂x∂vy)=0
which leads to
I
x
(
I
x
u
+
I
y
v
+
I
t
)
−
α
2
Δ
u
=
0
I
y
(
I
x
u
+
I
y
v
+
I
t
)
−
α
2
Δ
v
=
0
\begin{aligned} I_x(I_x u + I_y v + I_t) - \alpha^2 \Delta u = 0 \\ I_y(I_x u + I_y v + I_t) - \alpha^2 \Delta v = 0 \\ \end{aligned}
Ix(Ixu+Iyv+It)−α2Δu=0Iy(Ixu+Iyv+It)−α2Δv=0
Δ
=
∂
2
∂
x
2
+
∂
2
∂
y
2
\Delta = \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2}
Δ=∂x2∂2+∂y2∂2 with the operator
[
0
1
/
4
0
1
/
4
−
1
1
/
4
0
1
/
4
0
]
o
r
[
0
−
1
/
4
0
−
1
/
4
1
−
1
/
4
0
−
1
/
4
0
]
\begin{bmatrix} 0 & 1/4 & 0 \\ 1/4 & -1 & 1/4 \\ 0 & 1/4 & 0\\ \end{bmatrix} or \begin{bmatrix} 0 & -1/4 & 0 \\ -1/4 & 1 & -1/4 \\ 0 & -1/4 & 0\\ \end{bmatrix}
⎣⎡01/401/4−11/401/40⎦⎤or⎣⎡0−1/40−1/41−1/40−1/40⎦⎤
i.e.
f
x
x
+
f
y
y
=
f
c
e
n
t
e
r
−
f
a
v
e
r
a
g
e
f_{xx} + f_{yy} = f_{center} - f_{average}
fxx+fyy=fcenter−faverage
replace
Δ
u
\Delta u
Δu and
Δ
v
\Delta v
Δv, we get the discrete version
I
x
(
I
x
u
+
I
y
v
+
I
t
)
−
α
2
(
u
−
u
a
v
g
)
=
0
I
y
(
I
x
u
+
I
y
v
+
I
t
)
−
α
2
(
v
−
v
a
v
g
)
=
0
I_x(I_x u + I_y v + I_t) - \alpha^2 (u - u_{avg}) = 0 \\ I_y(I_x u + I_y v + I_t) - \alpha^2 (v - v_{avg}) = 0 \\
Ix(Ixu+Iyv+It)−α2(u−uavg)=0Iy(Ixu+Iyv+It)−α2(v−vavg)=0
Iteration
However, since the solution depends on the neighboring values of the flow field:
Δ
u
,
Δ
v
\Delta u, \Delta v
Δu,Δv, it must be repeated once the neighbors have been updated. The following iterative scheme is derived:
where the superscript k+1 denotes the next iteration, which is to be calculated and k is the last calculated result.
TODO
This is in essence a Matrix splitting method, similar to the Jacobi method, applied to the large, sparse system arising when solving for all pixels simultaneously.