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
7a22a928
Commit
7a22a928
authored
13 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
improc ass4: Source code cleanup.
parent
e54a3999
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
improc/ass4/gauss.py
+8
-8
8 additions, 8 deletions
improc/ass4/gauss.py
with
8 additions
and
8 deletions
improc/ass4/gauss.py
+
8
−
8
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
)
F
x
=
F
y
if
jorder
==
iorder
else
Gauss1
(
s
,
jorder
)
W
x
=
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.
"""
...
...
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