Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
3895c9fd
Commit
3895c9fd
authored
13 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
improc ass4: Updated separability section in report.
parent
df410367
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
improc/ass4/report/gauss_times_1d.pdf
+0
-0
0 additions, 0 deletions
improc/ass4/report/gauss_times_1d.pdf
improc/ass4/report/gauss_times_2d.pdf
+0
-0
0 additions, 0 deletions
improc/ass4/report/gauss_times_2d.pdf
improc/ass4/report/report.tex
+122
-6
122 additions, 6 deletions
improc/ass4/report/report.tex
with
122 additions
and
6 deletions
improc/ass4/report/gauss_times_1d.pdf
+
0
−
0
View file @
3895c9fd
No preview for this file type
This diff is collapsed.
Click to expand it.
improc/ass4/report/gauss_times_2d.pdf
+
0
−
0
View file @
3895c9fd
No preview for this file type
This diff is collapsed.
Click to expand it.
improc/ass4/report/report.tex
+
122
−
6
View file @
3895c9fd
...
@@ -18,29 +18,145 @@
...
@@ -18,29 +18,145 @@
\section
{
Analytical Local Structure
}
\section
{
Analytical Local Structure
}
\subsection
{
Derivatives
}
\subsection
{
Derivatives
}
\label
{
sub:derivatives
}
We have been given the following function:
We have been given the following function:
$$
f
(
x, y
)
=
A sin
(
Vx
)
+
B cos
(
Wy
)
$$
$$
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{table}
[H]
\begin{tabular}
{
rl
}
\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
$
\\
&
$
=
A cos
(
Vx
)
\cdot
V
+
B
\cdot
0
$
\\
&
$
=
AV cos
(
Vx
)
$
\\
&
$
=
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
$
\\
&
$
=
A
\cdot
0
-
B sin
(
Wy
)
\cdot
W
$
\\
&
$
=
-
BW sin
(
Wy
)
$
\\
&
$
=
-
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
)
$
\\
&
$
=
-
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
)
$
\\
&
$
=
-
BW
^
2
cos
(
Wy
)
$
\\
\end{tabular}
\end{tabular}
\end{table}
\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}
\end{document}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment