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
3ce74ceb
Commit
3ce74ceb
authored
Oct 21, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass4: Fixed function for Gaussian filter.
parent
4b7f8708
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
25 deletions
+7
-25
improc/ass4/canny.py
improc/ass4/canny.py
+1
-20
improc/ass4/gauss.py
improc/ass4/gauss.py
+6
-5
No files found.
improc/ass4/canny.py
View file @
3ce74ceb
#!/usr/bin/env python
#!/usr/bin/env python
from
matplotlib.pyplot
import
imread
,
imshow
,
subplot
,
show
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
numpy.linalg
import
norm
from
scipy.ndimage
import
convolve1d
from
scipy.ndimage
import
convolve1d
from
gauss
import
Gauss1
,
gD
from
gauss
import
Gauss1
,
gD
...
@@ -9,11 +9,6 @@ def in_image(p, F):
...
@@ -9,11 +9,6 @@ def in_image(p, F):
"""Check if given pixel coordinates p are within the bound of image 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
]
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
):
def
canny
(
F
,
s
,
Tl
=
None
,
Th
=
None
):
"""Apply the Canny Edge Detection algorithm with Gauss scale s to an
"""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
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):
...
@@ -36,20 +31,6 @@ def canny(F, s, Tl=None, Th=None):
G
[
p
]
=
norm
(
append
(
Gx
[
p
],
Gy
[
p
]))
G
[
p
]
=
norm
(
append
(
Gx
[
p
],
Gy
[
p
]))
A
[
p
]
=
int
(
round
(
arctan2
(
Gy
[
p
],
Gx
[
p
])
*
4
/
pi
+
1
))
%
4
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
# Non-maximum suppression
E
=
zeros
(
F
.
shape
)
E
=
zeros
(
F
.
shape
)
...
...
improc/ass4/gauss.py
View file @
3ce74ceb
#!/usr/bin/env python
#!/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
,
\
from
matplotlib.pyplot
import
imread
,
imshow
,
plot
,
xlabel
,
ylabel
,
show
,
\
subplot
,
xlim
,
savefig
subplot
,
xlim
,
savefig
from
mpl_toolkits.mplot3d
import
Axes3D
from
mpl_toolkits.mplot3d
import
Axes3D
...
@@ -30,14 +31,14 @@ def Gauss(s):
...
@@ -30,14 +31,14 @@ def Gauss(s):
return
W
/
W
.
sum
()
return
W
/
W
.
sum
()
def
f_gauss
(
x
,
s
):
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
):
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
):
def
f_gauss_der_2
(
x
,
s
):
return
(
x
**
2
-
s
**
2
)
*
e
**
-
(
x
**
2
/
(
2
*
s
**
2
))
\
return
(
x
**
2
-
s
**
2
)
*
e
xp
(
-
(
x
**
2
/
(
2
*
s
**
2
)
))
\
/
(
2
*
pi
*
s
**
6
)
/
(
sqrt
(
2
*
pi
)
*
s
**
5
)
def
Gauss1
(
s
,
order
=
0
):
def
Gauss1
(
s
,
order
=
0
):
"""Sample a one-dimensional Gaussian function of scale s."""
"""Sample a one-dimensional Gaussian function of scale s."""
...
...
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