📄 feature detectors - sobel 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/sobel.html -->
<HTML><HEAD><TITLE>Feature Detectors - Sobel 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 - Sobel Edge Detector-Dateien/home.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/left.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/canny.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/right.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/featops.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/up.gif"></A>
<HR>
<A name=1><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/mote.gif"></A>
<H1>Sobel Edge Detector</H1>
<P><STRONG>Common Names:</STRONG> Sobel, also related is Prewitt Gradient Edge
Detector
<P>
<H2>Brief Description</H2>
<P>The Sobel operator performs a 2-D spatial gradient measurement on an image
and so emphasizes regions of high spatial gradient that correspond to edges.
Typically it is used to find the approximate absolute gradient magnitude at each
point in an input greyscale image.
<P>
<H2>How It Works</H2>
<P>In theory at least, the operator consists of a pair of 3×3 <A
href="http://www.cee.hw.ac.uk/hipr/html/convolve.html">convolution masks</A> as
shown in Figure 1. One mask is simply the other rotated by 90°. This is very
similar to the <A href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts
Cross</A> operator.
<P><BR>
<BLOCKQUOTE><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/sobmasks.gif"><BR></BLOCKQUOTE>
<BLOCKQUOTE><STRONG>Figure 1</STRONG> Sobel convolution masks </BLOCKQUOTE><BR>
<P>These masks are designed to respond maximally to edges running vertically and
horizontally relative to the pixel grid, one mask for each of the two
perpendicular orientations. The masks can be applied separately to the input
image, to produce separate measurements of the gradient component in each
orientation (call these <EM>Gx</EM> and <EM>Gy</EM>). These can then be combined
together to find the absolute magnitude of the gradient at each point and the
orientation of that gradient. The gradient magnitude is given by:
<BLOCKQUOTE><IMG align=bottom
src="Feature Detectors - Sobel Edge Detector-Dateien/eqnrob1.gif">
</BLOCKQUOTE>Although typically, an approximate magnitude is computed using:
<BLOCKQUOTE><IMG align=bottom
src="Feature Detectors - Sobel Edge Detector-Dateien/eqnrob2.gif">
</BLOCKQUOTE>which is much faster to compute.
<P>The angle of orientation of the edge (relative to the pixel grid) giving rise
to the spatial gradient is given by:
<BLOCKQUOTE><IMG align=bottom
src="Feature Detectors - Sobel Edge Detector-Dateien/eqnrob3.gif">
</BLOCKQUOTE>In this case, orientation 0 is taken to mean that the direction of
maximum contrast from black to white runs from left to right on the image, and
other angles are measured anti-clockwise from this.
<P>Often, this absolute magnitude is the only output the user sees --- the two
components of the gradient are conveniently computed and added in a single pass
over the input image using the pseudo-convolution operator shown in Figure 2.
<P><BR>
<BLOCKQUOTE><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/sobmask2.gif"><BR></BLOCKQUOTE>
<BLOCKQUOTE><STRONG>Figure 2</STRONG> Pseudo-convolution masks used to quickly
compute approximate gradient magnitude </BLOCKQUOTE><BR>
<P>Using this mask the approximate magnitude is given by:
<BLOCKQUOTE><IMG align=bottom
src="Feature Detectors - Sobel Edge Detector-Dateien/eqnsob1.gif"> </BLOCKQUOTE>
<P>
<H2>Guidelines for Use</H2>
<P>The Sobel operator is slower to compute than the Roberts Cross operator, but
its larger convolution mask smooths the input image to a greater extent and so
makes the operator less sensitive to noise. The operator also generally produces
considerably higher output values for similar edges compared with the Roberts
Cross.
<P>As with the Roberts Cross operator, output values from the operator can
easily overflow the maximum allowed pixel value for image types that only
support smallish integer pixel values (<EM>e.g.</EM> 8-bit integer images). When
this happens the standard practice is to simply set overflowing output pixels to
the maximum allowed value. The problem can be avoided by using an image type
that supports pixel values with a larger range.
<P>Natural edges in images often lead to lines in the output image that are
several pixels wide due to the smoothing effect of the Sobel operator. Some <A
href="http://www.cee.hw.ac.uk/hipr/html/thin.html">thinning</A> may be desirable
to counter this. Failing that, some sort of hysteresis ridge tracking could be
used as in the <A href="http://www.cee.hw.ac.uk/hipr/html/canny.html">Canny
operator</A>.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/cln1sob1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/cln1sob1.gif"></A> shows
the results of applying the Sobel operator to <A
href="http://www.cee.hw.ac.uk/hipr/images/cln1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/cln1.gif"></A>. Compare
this with the equivalent Roberts cross output <A
href="http://www.cee.hw.ac.uk/hipr/images/cln1rob1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/cln1rob1.gif"></A>. Note
that the spurious noise that afflicted the Roberts cross output image is still
present in this image, but its intensity relative to the genuine lines has been
reduced, and so there is a good chance that we can get rid of this entirely by
thresholding. Also notice that the lines corresponding to edges have become
thicker compared with the Roberts cross output due to the increased smoothing of
the Sobel operator.
<P><A href="http://www.cee.hw.ac.uk/hipr/images/wdg2.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/wdg2.gif"></A> shows a
simpler scene containing just a single flat dark object against a lighter
background. Applying the Sobel operator produces <A
href="http://www.cee.hw.ac.uk/hipr/images/wdg2sob1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/wdg2sob1.gif"></A>. Note
that the lighting has been carefully set up to ensure that the edges of the
object are nice and sharp and free of shadows.
<P>The Sobel edge detector can also be applied to <EM>range images</EM> like <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2.gif"></A>. The
corresponding edge image is <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2sob1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2sob1.gif"></A>. All
edges in the image have been detected and can be nicely separated from the
background using a <A
href="http://www.cee.hw.ac.uk/hipr/html/threshld.html">threshold</A> of
<EM>150</EM>, as can be seen in <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2sob2.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2sob2.gif"></A>.
<P>Although the Sobel operator is not as sensitive to <A
href="http://www.cee.hw.ac.uk/hipr/html/noise.html">noise</A> as the <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts Cross</A>
operator, it still amplifies high frequencies. <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2noi2.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2noi2.gif"></A> is the
result of adding Gaussian noise with a standard deviation of <EM>15</EM> to the
original image. Applying the Sobel operator yields <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2sob5.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2sob5.gif"></A> and
thresholding the result at a value of <EM>150</EM> produces <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo2sob6.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo2sob6.gif"></A>. We can
see that the noise has increased during the edge detection and it is not
possible anymore to find a threshold which removes all noise pixels and at the
same time retains the edges of the objects.
<P>The object in the previous example contains sharp edges and its surface is
rather smooth. Therefore, we could (in the noise free case) easily detect the
boundary of the object without getting any erroneous pixels. A more difficult
task is to detect the boundary of <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ren1.gif"></A>, because it
contains many fine depth variations (<EM>i.e.</EM> resulting in intensity
changes in the image) on its surface. Applying the Sobel operator
straightforwardly yields <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1sob1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ren1sob1.gif"></A>. We can
see that the intensity of many pixels on the surface is as high as along the
actual edges. One reason is that the output of many edge pixels is greater than
the maximum pixel value and therefore they are `cut off' at <EM>255</EM>. To
avoid this overflow we <A
href="http://www.cee.hw.ac.uk/hipr/html/pixmult.html">scale</A> the range image
by a factor <EM>0.25</EM> prior to the edge detection and than <A
href="http://www.cee.hw.ac.uk/hipr/html/stretch.html">normalize</A> the output,
as can be seen in <A
href="http://www.cee.hw.ac.uk/hipr/images/ren1sob2.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ren1sob2.gif"></A>.
Although the result improved significantly, we still cannot find a threshold so
that a closed line along the boundary remains and all the noise disappears.
Compare this image with the results obtained with the <A
href="http://www.cee.hw.ac.uk/hipr/html/canny.html">Canny</A> edge detector.
<P><A name=2><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/mote.gif"></A>
<H2>Common Variants</H2>
<P>A related operator is the Prewitt gradient edge detector (not to be confused
with the <A href="http://www.cee.hw.ac.uk/hipr/html/prewitt.html">Prewitt
<EM>compass</EM> edge detector</A>). This works in a very similar way to the
Sobel operator but uses slightly different masks, as shown in Figure 3. This
mask produces similar results to the Sobel, but is not as <A
href="http://www.cee.hw.ac.uk/hipr/html/isotrop.html">isotropic</A> in its
response.
<P><BR>
<BLOCKQUOTE><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/prwgrad.gif"><BR></BLOCKQUOTE>
<BLOCKQUOTE><STRONG>Figure 3</STRONG> Masks for the Prewitt gradient edge
detector. </BLOCKQUOTE><BR>
<P>
<H2>Exercises</H2>
<P>
<OL>
<P>
<LI>Experiment with <A
href="http://www.cee.hw.ac.uk/hipr/html/threshld.html">thresholding</A> the
example images to see if noise can be eliminated while still retaining the
important edges.
<P></P>
<LI>How does the Sobel operator compare with the Roberts cross operator in
terms of noise rejection, edge detection and speed?
<P></P>
<LI>How well are the edges located using the Sobel operator? Why is this?
<P></P>
<LI>Apply the Sobel operator to <A
href="http://www.cee.hw.ac.uk/hipr/images/ufo1.gif"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/ufo1.gif"></A> and see if
you can use <A
href="http://www.cee.hw.ac.uk/hipr/html/threshld.html">thresholding</A> to
detect the edges of the object without obtaining noise. Compare the results
with the one obtained with the <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html">Roberts cross</A>
operator.
<P></P>
<LI>Under what conditions would you want to use the Sobel rather than the
Roberts cross operator? And when would you not want to use it?
<P></P></LI></OL>
<P>
<H2>References</H2>
<P><STRONG>R. Gonzalez and R. Woods</STRONG> <EM>Digital Image Processing</EM>,
Addison Wesley, 1992, pp 414 - 428.
<P><STRONG>R. Boyle and R. Thomas</STRONG> <EM>Computer Vision: A First
Course</EM>, Blackwell Scientific Publications, 1988, pp 48 - 50.
<P><STRONG>E. Davies</STRONG> <EM>Machine Vision: Theory, Algorithms and
Practicalities</EM> Academic Press, 1990, Chap 5.
<P><STRONG>D. Vernon</STRONG> <EM>Machine Vision</EM>, Prentice-Hall, 1991, Chap
5.
<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 - Sobel Edge Detector-Dateien/home.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/roberts.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/left.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/canny.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/right.gif"></A> <A
href="http://www.cee.hw.ac.uk/hipr/html/featops.html"><IMG
src="Feature Detectors - Sobel Edge Detector-Dateien/up.gif"></A><BR>
<HR>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -