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
1cf0b95f
Commit
1cf0b95f
authored
13 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
improc ass4: Finished Gaussian Derivatives and Canny Edge Detector sections in report.
parent
23aeccb1
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
+6
-4
6 additions, 4 deletions
improc/ass4/canny.py
improc/ass4/report/report.tex
+42
-0
42 additions, 0 deletions
improc/ass4/report/report.tex
with
48 additions
and
4 deletions
improc/ass4/canny.py
+
6
−
4
View file @
1cf0b95f
...
...
@@ -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
hysteresis thresholding.
"""
# Noise reduction by a Gaussian filter
F
=
gD
(
F
,
s
,
0
,
0
)
F
=
gD
(
F
,
1.4
,
0
,
0
)
# Find intensity gradient
W
=
Gauss1
(
1.4
,
1
)
W
=
Gauss1
(
s
,
1
)
Gx
=
convolve1d
(
F
,
W
,
axis
=
1
,
mode
=
'
nearest
'
)
Gy
=
convolve1d
(
F
,
W
,
axis
=
0
,
mode
=
'
nearest
'
)
G
=
zeros
(
F
.
shape
)
...
...
@@ -47,11 +47,12 @@ def canny(F, s, Tl=None, Th=None):
and
(
not
in_image
(
nb
,
G
)
or
g
>
G
[
nb
]):
E
[
y
,
x
]
=
g
# Only execute hysteresis thresholding if th
e
thresholds are specified
# Only execute hysteresis thresholding if
bo
th thresholds are specified
if
Tl
is
None
or
Th
is
None
:
return
E
# Hysteresis thresholding
# Scale the thresholds to the color range of the image
Tl
*=
(
E
.
max
()
-
E
.
min
())
/
255
Th
*=
(
E
.
max
()
-
E
.
min
())
/
255
T
=
zeros
(
F
.
shape
,
dtype
=
bool
)
...
...
@@ -64,7 +65,8 @@ def canny(F, s, Tl=None, Th=None):
E
[
0
,
x
]
=
E
[
F
.
shape
[
0
]
-
1
,
x
]
=
0
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
]:
return
...
...
This diff is collapsed.
Click to expand it.
improc/ass4/report/report.tex
+
42
−
0
View file @
1cf0b95f
...
...
@@ -167,4 +167,46 @@ are separable as well:
\end{tabular}
\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}
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