Download presentation
Presentation is loading. Please wait.
Published byKerry Mitchell Modified over 8 years ago
1
1 © 2010 Cengage Learning Engineering. All Rights Reserved. 1 Introduction to Digital Image Processing with MATLAB ® Asia Edition McAndrew ‧ Wang ‧ Tseng Chapter 5: Neighborhood Processing
2
2 © 2010 Cengage Learning Engineering. All Rights Reserved. 5.1 Introduction Move a mask A rectangle (usually with sides of odd length) or other shape over the given image Ch5-p.87
3
3 5.1 Introduction © 2010 Cengage Learning Engineering. All Rights Reserved. Mask values Ch5-p.88
4
4 5.1 Introduction © 2010 Cengage Learning Engineering. All Rights Reserved. Corresponding pixel values Ch5-p.88
5
5 FIGURE 5.2 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.89
6
6 5.1 Introduction © 2010 Cengage Learning Engineering. All Rights Reserved. Allied to spatial filtering is spatial convolution The filter must be rotated by 180° before multiplying and adding Ch5-p.89
7
7 5.1 Introduction © 2010 Cengage Learning Engineering. All Rights Reserved. EXAMPLE One important linear filter is to use a 3×3 mask and take the average of all nine values within the mask Ch5-p.90
8
8 5.1 Introduction © 2010 Cengage Learning Engineering. All Rights Reserved. The result of filtering x with 3×3 averaging filter Ch5-p.90
9
9 5.2 Notation © 2010 Cengage Learning Engineering. All Rights Reserved. It is convenient to describe a linear filter simply in terms of the coefficients of all the gray values of pixels within the mask The averaging filter Ch5-p.91-92
10
10 5.2 Notation © 2010 Cengage Learning Engineering. All Rights Reserved. EXAMPLE The filter would operate on gray values as Ch5-p.92
11
11 5.2.1 Edges of the Image © 2010 Cengage Learning Engineering. All Rights Reserved. What happens at the edge of the image, where the mask partly falls outside the image? There are a number of different approaches to dealing with this problem Ch5-p.92
12
12 5.2.1 Edges of the Image © 2010 Cengage Learning Engineering. All Rights Reserved. Ignore the edges Pad with zeros 000 0 0000000000 0 0 0 0 0 0 0 0 0 000000000000 0 0 000 Ch5-p.92
13
13 5.2.1 Edges of the Image © 2010 Cengage Learning Engineering. All Rights Reserved. Mirroring 2 2 3 4 5 4 3 2 1 2 3 4 4 3456734567 3456734567 6 5 4 3 2 1 2 3 4 5 7 7 6 5 4 3 2 1 2 3 4 5 5 3456534565 34563456 Ch5-p.93
14
14 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. filter2 function shape is optional; it describes the method for dealing with the edges ‘same’- pad with zeros ‘valid’- ignore the edges the result is a matrix of data type double!! Ch5-p.93
15
15 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.93
16
16 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.94
17
17 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. The result of ’same’ may also be obtained by padding with zeros and using ’valid’: Ch5-p.94
18
18 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. filter2(filter,image,’full’) returns a result larger than the original It does this by padding with zero and applying the filter at all places on and around the image where the mask intersects the image matrix Ch5-p.94
19
19 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.94
20
20 5.3 Filtering in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. filter2 provides no mirroring option The mirroring approach can be realized by placing the following codes before filter2 (filter,image,’valid’) Ch5-p.95
21
21 © 2010 Cengage Learning Engineering. All Rights Reserved. 5.3 Filtering in M ATLAB Where matrix x is extended to m_x, wr/wc is defined as one half total column/row number of the mask (chopping the decimal) Ch5-p.95
22
22 © 2010 Cengage Learning Engineering. All Rights Reserved. 5.3 Filtering in M ATLAB fspecial function h = fspecial(type, parameters) >>imshow(uint8(cf1)) >>imshow(cf1/255) or Ch5-p.95
23
23 FIGURE 5.4 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.97
24
24 5.4 Frequencies: Low- and High-Pass Filters © 2010 Cengage Learning Engineering. All Rights Reserved. Frequencies of an image are a measure of the amount by which gray values change with distance high-pass filter low-pass filter Ch5-p.98
25
25 5.4 Frequencies: Low- and High-Pass Filters © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.99
26
26 FIGURE 5.5 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.100
27
27 5.4 Frequencies: Low- and High-Pass Filters © 2010 Cengage Learning Engineering. All Rights Reserved. VALUES OUTSIDE THE RANGE 0–255 Make negative values positive Clip values Ch5-p.100
28
28 5.4 Frequencies: Low- and High-Pass Filters © 2010 Cengage Learning Engineering. All Rights Reserved. 0-255 Scaling transformation (uint8) Ch5-p.101
29
29 © 2010 Cengage Learning Engineering. All Rights Reserved. 5.4 Frequencies: Low- and High-Pass Filters 0-1 Scaling transformation (double) Ch5-p.101-102
30
30 © 2010 Cengage Learning Engineering. All Rights Reserved. FIGURE 5.6 Ch5-p.102
31
31 5.5 Gaussian Filters © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.103
32
32 FIGURE 5.8 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.104
33
33 5.5 Gaussian Filters © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.104
34
34 FIGURE 5.9 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.105
35
35 5.6 Edge Sharpening © 2010 Cengage Learning Engineering. All Rights Reserved. 5.6.1 Unsharp Masking Ch5-p.106
36
36 FIGURE 5.11 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.107
37
37 FIGURE 5.12 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.107
38
38 5.6.1 Unsharp Masking © 2010 Cengage Learning Engineering. All Rights Reserved. The unsharp option of fspecial produces such filters α = 0.5 Ch5-p.108
39
39 FIGURE 5.13 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.109
40
40 5.6.2 High-Boost Filtering © 2010 Cengage Learning Engineering. All Rights Reserved. Allied to unsharp masking filters are the high- boost filters where A is an amplification factor If A = 1, then the high-boost filter becomes an ordinary high-pass filter Ch5-p.109
41
41 5.6.2 High-Boost Filtering © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.111
42
42 FIGURE 5.14 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.111 >> x1=filter2(hb1, x); >> imshow(x1/255) >> x2=filter2(hb2, x); >> imshow(x2/255)
43
43 5.7 Nonlinear Filters © 2010 Cengage Learning Engineering. All Rights Reserved. Maximum filter Minimum filter Ch5-p.112
44
44 FIGURE 5.15 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.113
45
45 5.8 Region of Interest Processing © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.115
46
46 5.8.1 Regions of Interest in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.115-116
47
47 5.8.1 Regions of Interest in M ATLAB © 2010 Cengage Learning Engineering. All Rights Reserved. This will bring up the iguana image (if it isn’t shown already). Vertices of the ROI can be selected with the mouse Ch5-p.116
48
48 5.8.2 Region of Interest Filtering © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.116
49
49 FIGURE 5.18 © 2010 Cengage Learning Engineering. All Rights Reserved. Ch5-p.117
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.