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
1cf0b95f
Commit
1cf0b95f
authored
Nov 04, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass4: Finished Gaussian Derivatives and Canny Edge Detector sections in report.
parent
23aeccb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
4 deletions
+48
-4
improc/ass4/canny.py
improc/ass4/canny.py
+6
-4
improc/ass4/report/report.tex
improc/ass4/report/report.tex
+42
-0
No files found.
improc/ass4/canny.py
View file @
1cf0b95f
...
@@ -14,10 +14,10 @@ def canny(F, s, Tl=None, Th=None):
...
@@ -14,10 +14,10 @@ def canny(F, s, Tl=None, Th=None):
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
hysteresis thresholding."""
hysteresis thresholding."""
# Noise reduction by a Gaussian filter
# Noise reduction by a Gaussian filter
F
=
gD
(
F
,
s
,
0
,
0
)
F
=
gD
(
F
,
1.4
,
0
,
0
)
# Find intensity gradient
# Find intensity gradient
W
=
Gauss1
(
1.4
,
1
)
W
=
Gauss1
(
s
,
1
)
Gx
=
convolve1d
(
F
,
W
,
axis
=
1
,
mode
=
'nearest'
)
Gx
=
convolve1d
(
F
,
W
,
axis
=
1
,
mode
=
'nearest'
)
Gy
=
convolve1d
(
F
,
W
,
axis
=
0
,
mode
=
'nearest'
)
Gy
=
convolve1d
(
F
,
W
,
axis
=
0
,
mode
=
'nearest'
)
G
=
zeros
(
F
.
shape
)
G
=
zeros
(
F
.
shape
)
...
@@ -47,11 +47,12 @@ def canny(F, s, Tl=None, Th=None):
...
@@ -47,11 +47,12 @@ def canny(F, s, Tl=None, Th=None):
and
(
not
in_image
(
nb
,
G
)
or
g
>
G
[
nb
]):
and
(
not
in_image
(
nb
,
G
)
or
g
>
G
[
nb
]):
E
[
y
,
x
]
=
g
E
[
y
,
x
]
=
g
# Only execute hysteresis thresholding if
the
thresholds are specified
# Only execute hysteresis thresholding if
both
thresholds are specified
if
Tl
is
None
or
Th
is
None
:
if
Tl
is
None
or
Th
is
None
:
return
E
return
E
# Hysteresis thresholding
# Hysteresis thresholding
# Scale the thresholds to the color range of the image
Tl
*=
(
E
.
max
()
-
E
.
min
())
/
255
Tl
*=
(
E
.
max
()
-
E
.
min
())
/
255
Th
*=
(
E
.
max
()
-
E
.
min
())
/
255
Th
*=
(
E
.
max
()
-
E
.
min
())
/
255
T
=
zeros
(
F
.
shape
,
dtype
=
bool
)
T
=
zeros
(
F
.
shape
,
dtype
=
bool
)
...
@@ -64,7 +65,8 @@ def canny(F, s, Tl=None, Th=None):
...
@@ -64,7 +65,8 @@ def canny(F, s, Tl=None, Th=None):
E
[
0
,
x
]
=
E
[
F
.
shape
[
0
]
-
1
,
x
]
=
0
E
[
0
,
x
]
=
E
[
F
.
shape
[
0
]
-
1
,
x
]
=
0
def
follow_nb
(
y
,
x
):
def
follow_nb
(
y
,
x
):
"""Follow the neighbouring pixels of an edge pixel in E recursively."""
"""Follow the neighbouring pixels of an edge pixel in E recursively.
Add pixels with a value higher than Tl to the bitmap."""
if
T
[
y
,
x
]:
if
T
[
y
,
x
]:
return
return
...
...
improc/ass4/report/report.tex
View file @
1cf0b95f
...
@@ -167,4 +167,46 @@ are separable as well:
...
@@ -167,4 +167,46 @@ are separable as well:
\end{tabular}
\end{tabular}
\end{table}
\end{table}
The separability property is used in the
\texttt
{
gD
}
function, by calling the
\texttt
{
convolve1d
}
function separately for each direction. This implementation
yields the 2-jet of the cameraman image in figure
\ref
{
fig:jet
}
.
\begin{figure}
[H]
\label
{
fig:jet
}
\center
\includegraphics
[scale=.4]
{
jet
_
3.pdf
}
\caption
{
The result of
\texttt
{
python gauss.py jet 3
}
.
}
\end{figure}
\section
{
Canny Edge detector
}
The Canny Edge Detector is implemented in the file
\emph
{
canny.py
}
. For the
algorithm, we used the Wiki
page
\footnote
{
\url
{
http://en.wikipedia.org/wiki/Canny
\_
edge
\_
detector
}}
. The
different Wiki sections are marked by comments with similar descriptions. Since
the Wiki page is self-explanatory, we will not discuss the algorithm itself in
this report.
The program usage is as follows:
\begin{verbatim}
python canny.py SCALE [ LOWER
_
THRESHOLD HIGHER
_
THRESHOLD ]
\end{verbatim}
The scale is obviously used for finding the intensity gradient, and the
thresholds are used in the "Hysterisis thresholding" part. Note that the
thresholds are optional, because the assignment instructs to create a function
\texttt
{
canny(F, s)
}
without any arguments for thresholds. Therefore, we were
not sure whether to implement this section. If the thresholds are specified,
the resulting plot will contain an additional image containing a binary image
of edges. The thresholds can be specified in the range 0-255, they are scaled
down by the program to match the image's color range. An example execution of
edge detection on the cameraman image using a scale of 2, a lower threshold of
20 and a higher threshold of 60, can be viewed in figure
\ref
{
fig:canny
}
\begin{figure}
[H]
\label
{
fig:canny
}
\center
\includegraphics
[scale=.5]
{
canny
_
2
_
20
_
60.pdf
}
\caption
{
The result of
\texttt
{
python canny.py 2 20 60
}
.
}
\end{figure}
\end{document}
\end{document}
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