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
3ce74ceb
Commit
3ce74ceb
authored
13 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
improc ass4: Fixed function for Gaussian filter.
parent
4b7f8708
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
improc/ass4/canny.py
+1
-20
1 addition, 20 deletions
improc/ass4/canny.py
improc/ass4/gauss.py
+6
-5
6 additions, 5 deletions
improc/ass4/gauss.py
with
7 additions
and
25 deletions
improc/ass4/canny.py
+
1
−
20
View file @
3ce74ceb
#!/usr/bin/env python
from
matplotlib.pyplot
import
imread
,
imshow
,
subplot
,
show
from
numpy
import
arctan2
,
zeros
,
append
,
pi
#, argmax
from
numpy
import
arctan2
,
zeros
,
append
,
pi
from
numpy.linalg
import
norm
from
scipy.ndimage
import
convolve1d
from
gauss
import
Gauss1
,
gD
...
...
@@ -9,11 +9,6 @@ def in_image(p, F):
"""
Check if given pixel coordinates p are within the bound of image F.
"""
return
p
[
0
]
>=
0
and
p
[
1
]
>=
0
and
p
[
0
]
<
F
.
shape
[
0
]
and
p
[
1
]
<
F
.
shape
[
1
]
#def zero_crossing(a, b, F):
# """Cech if there is a zero crossing point between F[a] and F[b]."""
# return in_image(a, F) and in_image(b, F) \
# and ((F[a] < 0 and F[b] > 0) or (F[a] > 0 and F[b] < 0))
def
canny
(
F
,
s
,
Tl
=
None
,
Th
=
None
):
"""
Apply the Canny Edge Detection algorithm with Gauss scale s to an
image F. Optionally specify a low and high threshold (Tl and Th) for
...
...
@@ -36,20 +31,6 @@ def canny(F, s, Tl=None, Th=None):
G
[
p
]
=
norm
(
append
(
Gx
[
p
],
Gy
[
p
]))
A
[
p
]
=
int
(
round
(
arctan2
(
Gy
[
p
],
Gx
[
p
])
*
4
/
pi
+
1
))
%
4
#p = (x, y)
#compare = [(x, y - 1), (x, y + 1), (x + 1, y - 1), \
# (x - 1, y + 1), (x - 1, y), (x + 1, y), \
# (x - 1, y - 1), (x + 1, y + 1)]
#norms = zeros(8)
#for i, c in enumerate(compare):
# if zero_crossing(p, c, F):
# norms[i] = abs(F[p]) + abs(F[c])
#m = argmax(norms)
#G[p] = norms[m]
#A[p] = m >> 1
# Non-maximum suppression
E
=
zeros
(
F
.
shape
)
...
...
This diff is collapsed.
Click to expand it.
improc/ass4/gauss.py
+
6
−
5
View file @
3ce74ceb
#!/usr/bin/env python
from
numpy
import
zeros
,
arange
,
pi
,
e
,
ceil
,
meshgrid
,
array
,
dot
from
numpy
import
zeros
,
arange
,
meshgrid
,
array
,
dot
from
math
import
ceil
,
exp
,
pi
,
sqrt
from
matplotlib.pyplot
import
imread
,
imshow
,
plot
,
xlabel
,
ylabel
,
show
,
\
subplot
,
xlim
,
savefig
from
mpl_toolkits.mplot3d
import
Axes3D
...
...
@@ -30,14 +31,14 @@ def Gauss(s):
return
W
/
W
.
sum
()
def
f_gauss
(
x
,
s
):
return
e
**
-
(
x
**
2
/
(
2
*
s
**
2
))
/
(
2
*
pi
*
s
**
2
)
return
e
xp
(
-
(
x
**
2
/
(
2
*
s
**
2
))
)
/
(
sqrt
(
2
*
pi
)
*
s
)
def
f_gauss_der_1
(
x
,
s
):
return
-
x
*
e
**
-
(
x
**
2
/
(
2
*
s
**
2
))
/
(
2
*
pi
*
s
**
4
)
return
-
x
*
e
xp
(
-
(
x
**
2
/
(
2
*
s
**
2
))
)
/
(
sqrt
(
2
*
pi
)
*
s
**
3
)
def
f_gauss_der_2
(
x
,
s
):
return
(
x
**
2
-
s
**
2
)
*
e
**
-
(
x
**
2
/
(
2
*
s
**
2
))
\
/
(
2
*
pi
*
s
**
6
)
return
(
x
**
2
-
s
**
2
)
*
e
xp
(
-
(
x
**
2
/
(
2
*
s
**
2
))
)
\
/
(
sqrt
(
2
*
pi
)
*
s
**
5
)
def
Gauss1
(
s
,
order
=
0
):
"""
Sample a one-dimensional Gaussian function of scale s.
"""
...
...
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