Professional Documents
Culture Documents
Ch10-Image Segmentation
Ch10-Image Segmentation
Ch10-Image Segmentation
1
www.imageprocessingbook.com
Chapter 10
Image
Segmentation
www.ImageProcessingPlace.com
w.csie.ntnu.edu.tw/~violet/IP93/Chapter10.ppt
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 2
www.imageprocessingbook.com
Image Segmentation
Detection of Discontinuities
• There are three kinds of discontinuities of intensity: points,
lines and edges.
• The most common way to look for discontinuities is to scan a
small mask over the image. The mask determines which kind
of discontinuity to look for.
9
R w1 z1 w2 z 2 ... w9 z9 wi zi
i 1
Detection of Discontinuities
Point Detection
R T
where T : a nonnegative threshold
Detection of Discontinuities
Point Detection
>> f = imread('point.tif');
>> imshow(f);
>> w = [-1 -1 -1; -1 8 -1; -1 -1 -1]
w=
-1 -1 -1
-1 8 -1
-1 -1 -1
>> g = abs(imfilter(double(f), w));
>> T = max(g(:))
T=
391
>> g = g >= T;
>> imshow(g);
Detection of Discontinuities
Point Detection
Detection of Discontinuities
Line Detection
• Only slightly more common than point detection is to find a
one pixel wide line in an image.
• For digital images straight lines are only horizontal, vertical,
or diagonal (+ 45 or –45).
Detection of Discontinuities
Line Detection
>> f = imread('wirebond.tif');
>> imshow(f); % Fig 10.4(a)
>> w = [2 -1 -1; -1 2 -1; -1 -1 2];
w=
2 -1 -1
-1 2 -1
-1 -1 2
>> g = imfilter(double(f), w);
>> imshow(g, [ ]); % Fig 10.4(b)
>> gtop = g(1:120, 1:120);
>> figure, imshow(gtop, [ ]) % Fig 10.4(c)
>> gbot = g(end-119:end, end-119:end);
>> figure, imshow(gbot, [ ]) % Fig 10.4(d)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 9
www.imageprocessingbook.com
Detection of Discontinuities
Line Detection
>> g = abs(g);
>> figure, imshow(g, [ ]); % Fig 10.4(e)
>> T = max(g(:))
T=
1530
>> g = g >= T;
>> figure, imshow(g); % Fig 10.4(f)
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Gradient Operators
• First-order derivatives:
– The gradient of an image f(x,y) at location (x,y) is defined
as the vector:
G x f
x
f f
G y y
– The magnitude of this vector: f mag(f ) G G 2
x
2
y
1
2
Gx
– The direction of this vector: ( x, y ) tan
1
Gy
Detection of Discontinuities
Gradient Operators
Detection of Discontinuities
Gradient Operators
Detection of Discontinuities
Edge Detection Using Matlab
Detection of Discontinuities
Edge Detection Using Matlab
>> f = imread('building.tif');
>> imshow(f); % Fig. 10.6(a)
>> [gv, t] = edge(f, 'sobel', 'vertical');
>> imshow(gv); % Fig. 10.6(b)
>> t
t=
0.0516
>> gv = edge(f, 'sobel', 0.15, 'vertical');
>> imshow(gv); % Fig. 10.6(c)
>> gboth = edge(f, 'sobel', 0.15);
>> imshow(gboth); % Fig. 10.6(d)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 19
www.imageprocessingbook.com
Detection of Discontinuities
Edge Detection Using Matlab
Detection of Discontinuities
Edge Detection Using Matlab
>> wm45 = [0 1 2; -1 0 1; -2 -1 0]
wm45 =
0 1 2
-1 0 1
-2 -1 0
>> gm45 = imfilter(double(f), wm45, 'replicate');
>> T = 0.3*max(abs(gm45(:)))
T=
206.7000
>> gm45 = gm45 >= T;
>> figure, imshow(gm45); % Fig. 10.6(f)
© 2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed. 21
www.imageprocessingbook.com
Detection of Discontinuities
Edge Detection Using Matlab
References
1. Gonzalez R. C., Woods R. E., Eddins S. L., Digital Image
Processing Using Matlab, Pearson Education, 2006.
2. Gonzalez R. C., Woods R. E., Digital Image Processing,
Pearson Education, 2006.
3. http://www.imageprocessingplace.com/