📄 feature detectors - canny edge detector.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0044)http://www.cee.hw.ac.uk/hipr/html/canny.html -->
<HTML><HEAD><TITLE>Feature Detectors - Canny Edge Detector</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY><A href="http://www.cee.hw.ac.uk/hipr/html/hipr_top.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/home.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/sobel.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/left.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/prewitt.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/right.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/featops.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/up.gif"></A>
<HR>
<A name=1><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/mote.gif"></A>
<H1>Canny Edge Detector</H1>
<P><STRONG>Common Names:</STRONG> Canny edge detector
<P>
<H2>Brief Description</H2>
<P>The Canny operator was designed to be an optimal edge detector (according to
particular criteria --- there are other detectors around that also claim to be
optimal with respect to slightly different criteria). It takes as input a grey
scale image, and produces as output an image showing the positions of tracked
intensity discontinuities.
<P>
<H2>How It Works</H2>
<P>The Canny operator works in a multi-stage process. First of all the image is
smoothed by <A href="http://www.cee.hw.ac.uk/hipr/html/gsmooth.html">Gaussian
convolution</A>. Then a simple 2-D first derivative operator (somewhat like the
<A href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts Cross</A>) is
applied to the smoothed image to highlight regions of the image with high first
spatial derivatives. Edges give rise to ridges in the gradient magnitude image.
The algorithm then tracks along the top of these ridges and sets to zero all
pixels that are not actually on the ridge top so as to give a thin line in the
output, a process known as <EM>non-maximal suppression</EM>. The tracking
process exhibits hysteresis controlled by two thresholds: <EM>T1</EM> and
<EM>T2</EM> with <EM>T1 > T2</EM>. Tracking can only begin at a point on a
ridge higher than <EM>T1</EM>. Tracking then continues in both directions out
from that point until the height of the ridge falls below <EM>T2</EM>. This
hysteresis helps to ensure that noisy edges are not broken up into multiple edge
fragments.
<P><A name=guidelines><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/mote.gif"></A>
<H2>Guidelines for Use</H2>
<P>The effect of the Canny operator is determined by three parameters --- the
width of the Gaussian mask used in the smoothing phase, and the upper and lower
thresholds used by the tracker. Increasing the width of the Gaussian mask
reduces the detector's sensitivity to noise, at the expense of losing some of
the finer detail in the image. The localization error in the detected edges also
increases slightly as the Gaussian width is increased.
<P>Usually, the upper tracking threshold can be set quite high, and the lower
threshold quite low for good results. Setting the lower threshold too high will
cause noisy edges to break up. Setting the upper threshold too low increases the
number of spurious and undesirable edge fragments appearing in the output.
<P>One problem with the basic Canny operator is to do with Y-junctions
<EM>i.e.</EM> places where three ridges meet in the gradient magnitude image.
Such junctions can occur where an edge is partially occluded by another object.
The tracker will treat two of the ridges as a single line segment, and the third
one as a line that approaches, but doesn't quite connect to, that line segment.
<P>We use the image <A href="http://www.cee.hw.ac.uk/hipr/images/cln1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/cln1.gif"></A> to
demonstrate the effect of the Canny operator on a natural scene.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/cln1can1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/cln1can1.gif"></A> is
obtained using a Gaussian mask with standard deviation 1.0 and upper and lower
thresholds of 255 and 1 respectively. Most of the major edges are detected lots
of detail in has been picked out well --- note that this may be too much detail
for subsequent processing. The `Y-Junction effect' mentioned above can be seen
at the bottom left corner of the mirror.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/cln1can2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/cln1can2.gif"></A> is
obtained using the same mask size and upper threshold, but with the lower
threshold increased to 220. The edges have become more broken up than in the
previous image, which is likely to be bad for subsequent processing. Also the
vertical edges on the wall have not been detected along their full length.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/cln1can3.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/cln1can3.gif"></A> is
obtained by lowering the upper threshold to 128. The lower threshold is kept at
1 and the Gaussian standard deviation remains at 1.0. Many more faint edges are
detected along with some short `noisy' fragments. Notice that the detail in the
clown's hair is now picked out.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/cln1can4.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/cln1can4.gif"></A> is
obtained with the same thresholds as the previous image, but the Gaussian used
has a standard deviation of 2.0. Much of the detail on the wall is no longer
detected, but most of the strong edges remain. The edges also tend to be
smoother and less noisy.
<P>Edges in artificial scenes are often sharper and less complex than those in
natural scenes, and this generally improves the performance of any edge
detector.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/wdg2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/wdg2.gif"></A> shows such
an artificial scene.
<P>And <A href="http://www.cee.hw.ac.uk/hipr/images/wdg2can1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/wdg2can1.gif"></A> is the
output from the Canny operator.
<P>The Gaussian smoothing in the Canny edge detector fulfills <EM>2</EM>
purposes: First it can be used to control the amount of detail which appears in
the edge image and second, it can be used to suppress noise.
<P>To demonstrate how the Canny operator performs on noisy images we use <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2noi2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ufo2noi2.gif"></A>, which
contains Gaussian noise with a standard deviation of <EM>15</EM>. Neither the <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts cross</A> nor the
<A href="http://www.cee.hw.ac.uk/hipr/html/sobel.html">Sobel</A> operator are
able to detect the edges of the object while removing all the noise in the
image. Applying the Canny operator using a standard deviation of <EM>1.0</EM>
yields <A href="http://www.cee.hw.ac.uk/hipr/images/ufo2can1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ufo2can1.gif"></A>. All the
edges have been detected and almost all of the noise has been removed. For
comparison, <A href="http://www.cee.hw.ac.uk/hipr/images/ufo2sob6.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ufo2sob6.gif"></A> is the
result of applying the Sobel operator and <A
href="http://www.cee.hw.ac.uk/hipr/html/threshld.html">thresholding</A> the
output at a value of <EM>150</EM>.
<P>We use <A href="http://www.cee.hw.ac.uk/hipr/images/ren1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ren1.gif"></A> to
demonstrate how to control the details contained in the resulting edge image. <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1can1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ren1can1.gif"></A> is the
result of applying the Canny edge detector using a standard deviation of
<EM>1.0</EM> and an upper and lower threshold of <EM>255</EM> and <EM>1</EM>,
respectively. This image contains many details, however, for an automated
recognition task we might be interested to obtain only lines which correspond to
the boundaries of the objects. If we increase the standard deviation for the
Gaussian smoothing to <EM>1.8</EM>, the Canny operator yields <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1can2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ren1can2.gif"></A>. Now,
the edges corresponding to the uneveness of the surface have disappeared from
the image, but some edges corresponding to changes in the surface orientation
remain. Although these edges are `weaker' than the boundaries of the objects the
resulting pixel values are the same, due to the <A
href="http://www.cee.hw.ac.uk/hipr/html/wrap.html">saturation</A> of the image.
Hence, if we <A href="http://www.cee.hw.ac.uk/hipr/html/pixmult.html">scale
down</A> the image before the edge detection, we can use the upper threshold of
the edge tracker to remove the weaker edges. <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1can3.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ren1can3.gif"></A> is the
result of first scaling the image with <EM>0.25</EM> and then applying the Canny
operator using a standard deviation of <EM>1.8</EM> and an upper and lower
threshold of <EM>200</EM> and <EM>1</EM>, respectively. The image shows the
desired result that all the boundaries of the objects have been detected whereas
all other edges have been removed.
<P>Although the Canny edge detector allows us the find the intensity
discontinuities in an image, it is not guaranteed that these discontinuities
correspond to actual edges of the object. This is illustrated using <A
href="http://www.cee.hw.ac.uk/hipr/images/prt2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/prt2.gif"></A>. We obtain
<A href="http://www.cee.hw.ac.uk/hipr/images/prt2can1.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/prt2can1.gif"></A> by using
a standard deviation of <EM>1.0</EM> and an upper and lower threshold of
<EM>255</EM> and <EM>1</EM>, respectively. In this case, some edges of the
object do not appear in the image and many edges in the image originate only
from reflections on the object. It is a demanding task for an automated system
to interpret this image. We try to improve the edge image by decreasing the
upper threshold to <EM>150</EM>, as can be seen in <A
href="http://www.cee.hw.ac.uk/hipr/images/prt2can2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/prt2can2.gif"></A>. We now
obtain most of the edges of the object, but we also increase the amount of
noise. The result of further decreasing the upper threshold to <EM>100</EM> and
increasing the standard deviation to <EM>2</EM> is shown in <A
href="http://www.cee.hw.ac.uk/hipr/images/prt2can3.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/prt2can3.gif"></A>.
<P>
<H2>Common Variants</H2>
<P>The problem with Y-junctions mentioned above can be solved by including a
model of such junctions in the ridge tracker. This will ensure that no spurious
gaps are generated at these junctions.
<P>
<H2>Exercises</H2>
<P>
<OL>
<P>
<LI>Adjust the parameters of the Canny operator so that you can detect the
edges of <A href="http://www.cee.hw.ac.uk/hipr/images/ufo2noi2.gif"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/ufo2noi2.gif"></A> while
removing <EM>all</EM> of the noise.
<P></P>
<LI>What effect does increasing the Gaussian mask size have on the magnitudes
of the gradient maxima at edges? What change does this imply has to be made to
the tracker thresholds when the mask size is increased?
<P></P>
<LI>It is sometimes easier to evaluate edge detector performance after <A
href="http://www.cee.hw.ac.uk/hipr/html/threshld.html">thresholding</A> the
edge detector output at some low grey scale value (<EM>e.g.</EM> 1) so that
all detected edges are marked by bright white pixels. Try this out on the
third and fourth example images of the clown mentioned above. Comment on the
differences between the two images.
<P></P>
<LI>How does the Canny operator compare with the <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts</A> and <A
href="http://www.cee.hw.ac.uk/hipr/html/sobel.html">Sobel</A> edge detectors
in terms of speed? What do you think is the slowest stage of the process?
<P></P>
<LI>How does the Canny operator compare in terms of noise rejection and edge
detection with other operators such as the Roberts and Sobel operators?
<P></P>
<LI>How does the Canny operator compare with other edge detectors on simple
artificial 2-D scenes? And on more complicated natural scenes?
<P></P>
<LI>Under what situations might you choose to use the Canny operator rather
than the Roberts or Sobel operators? Under what situations would you
definitely not choose it? </LI></OL>
<P>
<H2>References</H2>
<P><STRONG>R. Boyle and R. Thomas</STRONG> <EM>Computer Vision: A First
Course</EM>, Blackwell Scientific Publications, 1988, p 52.
<P><STRONG>J. Canny</STRONG> <EM>A Computational Approach to Edge
Detection</EM>, IEEE Transactions on Pattern Analysis and Machine Intelligence,
Vol 8, No. 6, Nov 1986.
<P><STRONG>E. Davies</STRONG> <EM>Machine Vision: Theory, Algorithms and
Practicalities</EM> Academic Press, 1990, Chap 5.
<P><STRONG>R. Gonzalez and R. Woods</STRONG> <EM>Digital Image Processing</EM>,
Addison-Wesley Publishing Company, 1992, Chap 4.
<P>
<H2>Local Information</H2>
<P>General advice about the local HIPR installation is available <A
href="http://www.cee.hw.ac.uk/hipr/html/local.txt">here</A>
<P><BR><BR><BR>
<HR>
<STRONG><EM>Hypermedia Image Processing Reference</EM></STRONG><BR><BR>
<ADDRESS><A href="http://www.cee.hw.ac.uk/hipr/html/copyrght.html">©1994 Bob
Fisher, Simon Perkins, Ashley Walker and Erik Wolfart</A><BR>Department of
Artificial Intelligence<BR>University of Edinburgh<BR>UK<BR></ADDRESS>
<P><A href="http://www.cee.hw.ac.uk/hipr/html/hipr_top.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/home.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/sobel.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/left.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/prewitt.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/right.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/featops.html"><IMG
src="Feature Detectors - Canny Edge Detector-Dateien/up.gif"></A><BR>
<HR>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -