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
e54a3999
Commit
e54a3999
authored
Oct 24, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass4: Updated usage of gauss.py.
parent
3895c9fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
27 deletions
+31
-27
improc/ass4/gauss.py
improc/ass4/gauss.py
+27
-23
improc/ass4/report/gauss_1d_5_2_2.pdf
improc/ass4/report/gauss_1d_5_2_2.pdf
+0
-0
improc/ass4/report/gauss_2d_5.pdf
improc/ass4/report/gauss_2d_5.pdf
+0
-0
improc/ass4/report/report.tex
improc/ass4/report/report.tex
+4
-4
No files found.
improc/ass4/gauss.py
View file @
e54a3999
...
...
@@ -8,12 +8,6 @@ from scipy.ndimage import convolve, convolve1d
from
time
import
time
from
sys
import
argv
,
exit
def
exit_with_usage
():
"""Print an error message with the program's usage and exit the program."""
print
'Usage: python %s timer METHOD [ REPEAT ] | diff SCALE'
\
' | der SCALE IORDER JORDER'
%
argv
[
0
]
exit
(
1
)
def
Gauss
(
s
):
"""Sample a two-dimensional Gaussian function of scale s."""
size
=
int
(
ceil
(
3
*
s
))
...
...
@@ -80,13 +74,34 @@ def plot_kernel(W, ax):
ax
.
set_ylabel
(
'x'
)
ax
.
set_zlabel
(
'g(x, y)'
)
def
exit_with_usage
():
"""Print an error message with the program's usage and exit the program."""
print
'Usage: python %s ( 2d SCALE | 1d SCALE IORDER JORDER'
\
' | timer METHOD [ REPEAT ] )'
%
argv
[
0
]
exit
(
1
)
if
__name__
==
'__main__'
:
if
len
(
argv
)
<
2
:
exit_with_usage
()
F
=
imread
(
'cameraman.png'
)
if
argv
[
1
]
==
'der'
:
if
argv
[
1
]
==
'2d'
:
# Calculate and plot the convolution of the given scale
if
len
(
argv
)
<
3
:
exit_with_usage
()
s
=
float
(
argv
[
2
])
W
=
Gauss
(
s
)
G
=
convolve
(
F
,
W
,
mode
=
'nearest'
)
# Show the original image, kernel and convoluted image respectively
subplot
(
131
)
imshow
(
F
,
cmap
=
'gray'
)
plot_kernel
(
W
,
subplot
(
132
,
projection
=
'3d'
))
subplot
(
133
)
imshow
(
G
,
cmap
=
'gray'
)
elif
argv
[
1
]
==
'1d'
:
if
len
(
argv
)
<
5
:
exit_with_usage
()
...
...
@@ -96,10 +111,12 @@ if __name__ == '__main__':
iorder
=
int
(
argv
[
3
])
jorder
=
int
(
argv
[
4
])
G
=
gD
(
F
,
s
,
iorder
,
jorder
)
# Create a 2D weight function for plotting purposes only
Fy
=
matrix
([
Gauss1
(
s
,
iorder
)])
Fx
=
Fy
if
jorder
==
iorder
else
matrix
([
Gauss1
(
s
,
jorder
)])
W
=
Fy
.
T
*
Fx
G
=
gD
(
F
,
s
,
iorder
,
jorder
)
# Show the original image, kernel and convoluted image respectively
subplot
(
131
)
...
...
@@ -140,20 +157,7 @@ if __name__ == '__main__':
xlabel
(
's'
)
ylabel
(
'time (s)'
)
plot
(
S
,
times
,
'o-'
)
elif
argv
[
1
]
==
'diff'
:
# Calculate and plot the convolution of the given scale
if
len
(
argv
)
<
3
:
exit_with_usage
()
s
=
float
(
argv
[
2
])
W
=
Gauss
(
s
)
G
=
convolve
(
F
,
W
,
mode
=
'nearest'
)
# Show the original image, kernel and convoluted image respectively
subplot
(
131
)
imshow
(
F
,
cmap
=
'gray'
)
plot_kernel
(
W
,
subplot
(
132
,
projection
=
'3d'
))
subplot
(
133
)
imshow
(
G
,
cmap
=
'gray'
)
else
:
exit_with_usage
()
show
()
improc/ass4/report/gauss_
der
_5_2_2.pdf
→
improc/ass4/report/gauss_
1d
_5_2_2.pdf
View file @
e54a3999
File moved
improc/ass4/report/gauss_
diff
_5.pdf
→
improc/ass4/report/gauss_
2d
_5.pdf
View file @
e54a3999
File moved
improc/ass4/report/report.tex
View file @
e54a3999
...
...
@@ -84,14 +84,14 @@ 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
\ref
{
fig:gauss-
2d
}
. The subplots respectively show the original image, the
Gaussian kernel and the convolved image.
\begin{figure}
[H]
\label
{
fig:gauss-
diff
}
\label
{
fig:gauss-
2d
}
\hspace
{
-5cm
}
\includegraphics
[scale=.6]
{
gauss
_
diff
_
5.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py
diff
5
}
.
}
\includegraphics
[scale=.6]
{
gauss
_
2d
_
5.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py
2d
5
}
.
}
\end{figure}
\subsection
{
Measuring Performance
}
...
...
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