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
7a22a928
Commit
7a22a928
authored
Oct 24, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass4: Source code cleanup.
parent
e54a3999
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
improc/ass4/gauss.py
improc/ass4/gauss.py
+8
-8
No files found.
improc/ass4/gauss.py
View file @
7a22a928
...
@@ -16,7 +16,7 @@ def Gauss(s):
...
@@ -16,7 +16,7 @@ def Gauss(s):
t
=
float
(
s
)
**
2
t
=
float
(
s
)
**
2
a
=
1
/
(
2
*
pi
*
t
)
a
=
1
/
(
2
*
pi
*
t
)
# Sample the Gaussian function
# Sample the
2D
Gaussian function
for
x
in
xrange
(
r
):
for
x
in
xrange
(
r
):
for
y
in
xrange
(
r
):
for
y
in
xrange
(
r
):
W
[
x
,
y
]
=
a
*
exp
(
-
(((
x
-
size
)
**
2
+
(
y
-
size
)
**
2
)
/
(
2
*
t
)))
W
[
x
,
y
]
=
a
*
exp
(
-
(((
x
-
size
)
**
2
+
(
y
-
size
)
**
2
)
/
(
2
*
t
)))
...
@@ -25,16 +25,16 @@ def Gauss(s):
...
@@ -25,16 +25,16 @@ def Gauss(s):
return
W
/
W
.
sum
()
return
W
/
W
.
sum
()
def
f_gauss
(
x
,
s
):
def
f_gauss
(
x
,
s
):
"""Return the Gaussian function for a given x and scale."""
"""Return the
value of a 1D
Gaussian function for a given x and scale."""
return
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
s
)
return
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
s
)
def
f_gauss_der_1
(
x
,
s
):
def
f_gauss_der_1
(
x
,
s
):
"""Return the first derivative of the Gaussian function for a given x
"""Return the first derivative of the
1D
Gaussian function for a given x
and scale."""
and scale."""
return
-
x
*
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
s
**
3
)
return
-
x
*
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
/
(
sqrt
(
2
*
pi
)
*
s
**
3
)
def
f_gauss_der_2
(
x
,
s
):
def
f_gauss_der_2
(
x
,
s
):
"""Return the second derivative of the Gaussian function for a given x
"""Return the second derivative of the
1D
Gaussian function for a given x
and scale."""
and scale."""
return
(
x
**
2
-
s
**
2
)
*
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
\
return
(
x
**
2
-
s
**
2
)
*
exp
(
-
(
x
**
2
/
(
2
*
s
**
2
)))
\
/
(
sqrt
(
2
*
pi
)
*
s
**
5
)
/
(
sqrt
(
2
*
pi
)
*
s
**
5
)
...
@@ -58,11 +58,11 @@ def Gauss1(s, order=0):
...
@@ -58,11 +58,11 @@ def Gauss1(s, order=0):
def
gD
(
F
,
s
,
iorder
,
jorder
):
def
gD
(
F
,
s
,
iorder
,
jorder
):
"""Create the Gaussian derivative convolution of image F."""
"""Create the Gaussian derivative convolution of image F."""
F
y
=
Gauss1
(
s
,
iorder
)
W
y
=
Gauss1
(
s
,
iorder
)
Fx
=
F
y
if
jorder
==
iorder
else
Gauss1
(
s
,
jorder
)
Wx
=
W
y
if
jorder
==
iorder
else
Gauss1
(
s
,
jorder
)
G
=
convolve1d
(
F
,
F
y
,
axis
=
0
,
mode
=
'nearest'
)
G
=
convolve1d
(
F
,
W
y
,
axis
=
0
,
mode
=
'nearest'
)
return
convolve1d
(
G
,
F
x
,
axis
=
1
,
mode
=
'nearest'
)
return
convolve1d
(
G
,
W
x
,
axis
=
1
,
mode
=
'nearest'
)
def
plot_kernel
(
W
,
ax
):
def
plot_kernel
(
W
,
ax
):
"""Create a 3D plot of a kernel."""
"""Create a 3D plot of a kernel."""
...
...
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