Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
3895c9fd
Commit
3895c9fd
authored
Oct 24, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass4: Updated separability section in report.
parent
df410367
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
6 deletions
+122
-6
improc/ass4/report/gauss_times_1d.pdf
improc/ass4/report/gauss_times_1d.pdf
+0
-0
improc/ass4/report/gauss_times_2d.pdf
improc/ass4/report/gauss_times_2d.pdf
+0
-0
improc/ass4/report/report.tex
improc/ass4/report/report.tex
+122
-6
No files found.
improc/ass4/report/gauss_times_1d.pdf
View file @
3895c9fd
No preview for this file type
improc/ass4/report/gauss_times_2d.pdf
View file @
3895c9fd
No preview for this file type
improc/ass4/report/report.tex
View file @
3895c9fd
...
...
@@ -18,29 +18,145 @@
\section
{
Analytical Local Structure
}
\subsection
{
Derivatives
}
\label
{
sub:derivatives
}
We have been given the following function:
$$
f
(
x, y
)
=
A sin
(
Vx
)
+
B cos
(
Wy
)
$$
The partial derivatives
$
f
_
x, f
_
y, f
_{
xx
}
, f
_{
xy
}$
and
$
f
_{
yy
}$
can be derived as follows:
The partial derivatives
$
f
_
x, f
_
y, f
_{
xx
}
, f
_{
xy
}$
and
$
f
_{
yy
}$
can be
derived as follows:
\begin{table}
[H]
\begin{tabular}
{
rl
}
$
f
_
x
$
&
$
=
A
\frac
{
\delta
}{
\delta
x
}
sin
(
Vx
)
+
B
\frac
{
\delta
}{
\delta
x
}
cos
(
Wy
)
$
\\
$
f
_
x
$
&
$
=
\frac
{
\delta
f
}{
\delta
x
}$
\\
&
$
=
A
\frac
{
\delta
}{
\delta
x
}
sin
(
Vx
)
+
B
\frac
{
\delta
}{
\delta
x
}
cos
(
Wy
)
$
\\
&
$
=
A cos
(
Vx
)
\cdot
V
+
B
\cdot
0
$
\\
&
$
=
AV cos
(
Vx
)
$
\\
&
\\
$
f
_
y
$
&
$
=
A
\frac
{
\delta
}{
\delta
y
}
sin
(
Vx
)
+
B
\frac
{
\delta
}{
\delta
y
}
cos
(
Wy
)
$
\\
$
f
_
y
$
&
$
=
\frac
{
\delta
f
}{
\delta
y
}$
\\
&
$
=
A
\frac
{
\delta
}{
\delta
y
}
sin
(
Vx
)
+
B
\frac
{
\delta
}{
\delta
y
}
cos
(
Wy
)
$
\\
&
$
=
A
\cdot
0
-
B sin
(
Wy
)
\cdot
W
$
\\
&
$
=
-
BW sin
(
Wy
)
$
\\
&
\\
$
f
_{
xx
}$
&
$
=
AV
\frac
{
\delta
}{
\delta
x
}
cos
(
Vx
)
$
\\
$
f
_{
xx
}$
&
$
=
\frac
{
\delta
f
_
x
}{
\delta
x
}$
\\
&
$
=
AV
\frac
{
\delta
}{
\delta
x
}
cos
(
Vx
)
$
\\
&
$
=
-
AV
^
2
sin
(
Vx
)
$
\\
&
\\
$
f
_{
xy
}$
&
$
=
AV
\frac
{
\delta
}{
\delta
y
}
cos
(
Vx
)
=
0
$
\\
$
f
_{
xy
}$
&
$
=
\frac
{
\delta
f
_
x
}{
\delta
y
}
=
AV
\frac
{
\delta
}{
\delta
y
}
cos
(
Vx
)
=
0
$
\\
&
\\
$
f
_{
yy
}$
&
$
=
-
BW
\frac
{
\delta
}{
\delta
y
}
sin
(
Wy
)
$
\\
$
f
_{
yy
}$
&
$
=
\frac
{
\delta
f
_
y
}{
\delta
y
}$
\\
&
$
=
-
BW
\frac
{
\delta
}{
\delta
y
}
sin
(
Wy
)
$
\\
&
$
=
-
BW
^
2
cos
(
Wy
)
$
\\
\end{tabular}
\end{table}
\pagebreak
\subsection
{
Plots
}
The following plots show
$
f
(
x, y
)
$
and its first and second derivatives. The
image on the left shows
$
f
_
x
$
and
$
f
_
y
$
. The image on the right shows
$
f
_{
xx
}$
and
$
f
_{
yy
}$
in a quiver plot over
$
f
(
x, y
)
$
. The arrows point towards the
largest increase of gray value, which means that the derivations in chapter
\ref
{
sub:derivatives
}
are correct.
\begin{figure}
[H]
\hspace
{
-2cm
}
\includegraphics
[scale=.8]
{
samples.pdf
}
\caption
{
Plots of
$
f
(
x, y
)
$
and its first and second derivatives.
}
\end{figure}
\section
{
Gaussian Convolution
}
\subsection
{
Implementation
}
All Gaussian functions are implemented in the file
\emph
{
gauss.py
}
. The
\texttt
{
Gauss
}
function fills a 2D array with the values of the 2D Gaussian
function
\footnote
{
\label
{
footnote:gaussian-filter
}
\url
{
http://en.wikipedia.org/wiki/Gaussian
_
filter
}}
:
$$
g
_{
2
D
}
(
x, y
)
=
\frac
{
1
}{
2
\pi
\sigma
^
2
}
e
^{
-
\frac
{
x
^
2
+
y
^
2
}{
2
\sigma
^
2
}}$$
This function converges to zero, but never actually equals zero. The filter's
size is therefore chosen to be
$
\lceil
6
*
\sigma
\rceil
$
in each direction by
convention (since values for
$
x,y >
3
*
\sigma
$
are negligible). Finally,
because the sum of the filter should be equal to 1, it is divided by its own
sum.
The result of the
\texttt
{
Gauss
}
function is shown in figure
\ref
{
fig:gauss-diff
}
. The subplots respectively show the original image, the
Gaussian kernel and the convolved image.
\begin{figure}
[H]
\label
{
fig:gauss-diff
}
\hspace
{
-5cm
}
\includegraphics
[scale=.6]
{
gauss
_
diff
_
5.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py diff 5
}
.
}
\end{figure}
\subsection
{
Measuring Performance
}
We've timed the runtime of the
\texttt
{
Gauss
}
function for
$
\sigma
=
1
,
2
,
3
,
5
,
7
,
9
,
11
,
15
,
19
$
, the results are in figure
\ref
{
fig:times-2d
}
. The graph shows a computational complexity of
$
\mathcal
{
O
}
(
\sigma
^
2
)
$
.
\begin{figure}
[H]
\label
{
fig:times-2d
}
\center
\includegraphics
[scale=.5]
{
gauss
_
times
_
2d.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py timer 2d 5
}
(so, each
timing has been repeated 5 times and then averaged).
}
\end{figure}
\section
{
Separable Gaussian Convolution
}
\subsection
{
Implementation
}
The
\texttt
{
Gauss1
}
function uses the 1D Gaussian
function
\ref
{
footnote:gaussian-filter
}
:
$$
g
_{
1
D
}
(
x
)
=
\frac
{
1
}{
\sqrt
{
2
\pi
}
\cdot
\sigma
}
e
^{
-
\frac
{
x
^
2
}{
2
\sigma
^
2
}}$$
This function returns a 1D array of kernel values, which is used by the
function
\texttt
{
convolve1d
}
. Using the separability property, the following
code snippets produce the same result:
\begin{verbatim}
W = Gauss1(s)
G = convolve1d(F, W, axis=0, mode='nearest')
G = convolve1d(G, W, axis=1, mode='nearest')
\end{verbatim}
as opposed to:
\begin{verbatim}
G = convolve(F, Gauss(s), mode='nearest')
\end{verbatim}
The timing results of the first code snippet are displayed in figure
\ref
{
fig:times-1d
}
. The graphs shows that
\texttt
{
Gauss1
}
has a computational
complexity of
$
\mathcal
{
O
}
(
\sigma
)
$
, which is much faster than the 2D
convolution (certainly for higher scales).
\begin{figure}
[H]
\label
{
fig:times-1d
}
\center
\includegraphics
[scale=.5]
{
gauss
_
times
_
1d.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py timer 1d 50
}
.
}
\end{figure}
\section
{
Gaussian Derivatives
}
\subsection
{
Separability
}
We can show analytically that all derivatives of the 2D Gaussian function
are separable as well:
\begin{table}
[H]
\begin{tabular}
{
rl
}
$
$
&
$
=
$
\\
\end{tabular}
\end{table}
\end{document}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment