-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMath.tex
74 lines (60 loc) · 2.19 KB
/
Math.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
\documentclass{article}
% Packages
% ---
\usepackage{amsmath}
\usepackage[margin=0.7in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\begin{document}
A 2D gaussian filter is trivially converted into the generating vector by simply setting $y=0$ and normalizing, and this is done for the detection filters. This is not so easy for the other filter they use:
The spatial filter generation uses:
\begin{align}
f(x,y)=a_1e^{-a_2(x^2+y^2)}+b_1e^{-b_2(x^2+y^2)}
\end{align}
As a sum of gaussians, we need to find a way to create two corresponding vectors.
$f(x,y)$ is used to create an $NxN$ matrix $F$ that will be the convolution kernel:
\begin{align}
F_{i,j}=f(i-r,j-r),
\end{align}
with $N=2r+1$ and $i,j$ spanning $[-r,r]$.
Note that $F$ is then normalized into $\tilde{F}$:
\begin{align}
\tilde{F}=F/S_F\\
S_F=\sum_i\sum_j F_{i,j}
\end{align}
This notation means every element of the matrix $F$ is divided by $S_F$.
We construct the correct vectors $g_1$ and $g_2$:
\begin{align}
g_1(x)=\sqrt{a_1}e^{-a_2x^2}\\
g_2(x)=\sqrt{b_1}e^{-b_2x^2}.
\end{align}
They have with the following property:
\begin{align}
F=g_1\otimes g_1+g_2\otimes g_2\\
F_{i,j}=g_1(j) * g_1(i) + g_2(j) * g_2(i),
\end{align}
with the crossed circle denoting the outer product.
Because $F$ is normalized, we need to find the normalization for our vectors too, characterized by:
\begin{align}
\tilde{F}=\tilde{G}= \frac{g_1\otimes g_1+g_2\otimes g_2}{S_G}.
\end{align}
By identification, we trivially have:
\begin{align}
S_G=S_F
\end{align}
We write the normalization:
\begin{align}
\tilde{g_1}\otimes \tilde{g_1} &=\frac{g_1\otimes g_1}{S(g_1)^2+S(g_2)^2}\\
\texttt{with:} \tilde{g_1} &=\alpha_1 g_1\\
\alpha g_1\otimes \alpha g_1 &=\frac{g_1\otimes g_1}{S(g_1)^2+S(g_2)^2}\\
\alpha^2 g_1\otimes g_1 &=\frac{g_1\otimes g_1}{S(g_1)^2+S(g_2)^2}\\
\texttt{by identification: } \alpha &=\frac{1}{\sqrt{S(g_1)^2+S(g_2)^2}}\\
\end{align}
So, we compute our vectors this way to create a separable convolution of the sum of gaussians.
Here in pseudocode for the convolution:
\begin{lstlisting}
c1=convolve1D(image, alpha*g_1, alpha*g_1)
c2=convolve1D(image, alpha*g_2, alpha*g_2)
result=c1+c2.
\end{lstlisting}
\end{document}