Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007
description
Transcript of Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007
![Page 1: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/1.jpg)
Digital Image ProcessingChapter 3:
Image Enhancement in the Spatial Domain
15 June 2007
![Page 2: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/2.jpg)
Spatial Domain Spatial Domain
What is spatial domain The space where all pixels form an image
In spatial domain we can represent an image by f(x,y)where x and y are coordinates along x and y axis with respect to an origin There is duality between Spatial and Frequency Domains
Images in the spatial domain are pictures in the xy planewhere the word “distance” is meaningful.
Using the Fourier transform, the word “distance” is lost but the word “frequency” becomes alive.
![Page 3: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/3.jpg)
Image EnhancementImage Enhancement
Image Enhancement means improvement of images to be suitable for specific applications. Example:
Note: each image enhancement technique that is suitable for one application may not be suitable for other applications.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 4: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/4.jpg)
Image Enhancement ExampleImage Enhancement Example
Original image Enhanced image using Gamma correction
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 5: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/5.jpg)
= Image enhancement using processes performed in the Spatial domain resulting in images in the Spatial domain.We can written as
Image Enhancement in the Spatial DomainImage Enhancement in the Spatial Domain
( , ) ( , )g x y T f x y
where f(x,y) is an original image, g(x,y) is an output and T[ ] is a function defined in the area around (x,y)
Note: T[ ] may have one input as a pixel value at (x,y) only ormultiple inputs as pixels in neighbors of (x,y) depending in each function. Ex. Contrast enhancement uses a pixel value at (x,y) only for an input while smoothing filte use several pixels around (x,y) as inputs.
![Page 6: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/6.jpg)
Types of Image Enhancement in the Spatial DomainTypes of Image Enhancement in the Spatial Domain- Single pixel methods
- Gray level transformations Example
- Historgram equalization- Contrast stretching
- Arithmetic/logic operations Examples
- Image subtraction- Image averaging
- Multiple pixel methodsExamples
Spatial filtering - Smoothing filters- Sharpening filters
![Page 7: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/7.jpg)
Gray Level TransformationGray Level Transformation
Transforms intensity of an original image into intensity of an output image using a function:
( )s T r
where r = input intensity and s = output intensity
Example: Contrast enhancement
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 8: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/8.jpg)
Image NegativeImage Negative
White
Black
Input intensity
Out
put i
nten
sity
Originaldigital
mammogram
1s L r
L = the number of gray levels
0 L-1
L-1
Negativedigital
mammogram
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Black White
![Page 9: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/9.jpg)
Log TransformationsLog Transformations
Fourierspectrum
Log Tr. ofFourier
spectrum
log( 1)s c r Application
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 10: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/10.jpg)
Power-Law TransformationsPower-Law Transformations
s cr
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 11: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/11.jpg)
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
Desired image
Image displayed
atMonitor
AfterGamma
correction
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Image displayed
atMonitor
![Page 12: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/12.jpg)
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
MRI Image after Gamma Correction
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 13: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/13.jpg)
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
Ariel imagesafter GammaCorrection
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 14: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/14.jpg)
Contrast StretchingContrast StretchingBefore contrast enhancement
After
Contrast means the difference between the brightest and darkest intensities
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 15: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/15.jpg)
How to know where the contrast is enhanced ? How to know where the contrast is enhanced ? Notice the slope of T(r)- if Slope > 1 Contrast increases- if Slope < 1 Contrast decrease- if Slope = 1 no change
r
s
Smallerr yields wider s= increasing Contrast
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 16: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/16.jpg)
Gray Level SlicingGray Level Slicing
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 17: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/17.jpg)
Bit-plane SlicingBit-plane Slicing
Bit 7 Bit 6
Bit 2 Bit 1
Bit
5
Bit
3
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 18: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/18.jpg)
HistogramHistogram
Histogram = Graph of population frequencies
0
2
4
6
8
10
A B+ B C+ C D+ D F
No. ofStudents
Grades of the course 178 xxx
![Page 19: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/19.jpg)
Histogram of an ImageHistogram of an Image
( )k kh r n
จำ�นว
น pi
xel
จำ�นว
น pi
xel
= graph of no. of pixels vs intensities
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Bright image has histogram on the right
Dark image has histogram on the left
![Page 20: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/20.jpg)
Histogram of an Image (cont.)Histogram of an Image (cont.)
low contrast image has narrow histogram
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
high contrast image has wide histogram
![Page 21: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/21.jpg)
Histogram ProcessingHistogram Processing
= intensity transformation based on histogram information to yield desired histogram
- Histogram equalization
- Histogram matching
To make histogram distributed uniformly
To make histogram as the desire
![Page 22: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/22.jpg)
Monotonically Increasing FunctionMonotonically Increasing Function
= Function that is only increasing or constant
)(rTs
Properties of Histogram processing function
1. Monotonically increasing function
2. 10for 1)(0 rrT
![Page 23: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/23.jpg)
Probability Density FunctionProbability Density Function
and relation between s and r is
Histogram is analogous to Probability Density Function (PDF) which represent density of population
Let s and r be Random variables with PDF ps(s) and pr(r ) respectively
)(rTs
We get
dsdrrpsp rs )()(
![Page 24: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/24.jpg)
r
r dwwprTs0
)()(
Histogram EqualizationHistogram Equalization
Let
We get
1)(
1)()(
1)(
1)()()(
0
rp
rp
dr
dwwpdrp
drdsrp
dsdrrpsp
rrr
r
r
rrs
!
![Page 25: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/25.jpg)
Histogram EqualizationHistogram Equalization
Formula in the previous slide is for a continuous PDFFor Histogram of Digital Image, we use
k
j
j
k
jjrkk
Nn
rprTs
0
0
)()(
nj = the number of pixels with intensity = jN = the number of total pixels
![Page 26: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/26.jpg)
Histogram Equalization ExampleHistogram Equalization Example
Intensity # pixels
0 20
1 5
2 25
3 10
4 15
5 5
6 10
7 10
Total 100
Accumulative Sum of Pr
20/100 = 0.2
(20+5)/100 = 0.25
(20+5+25)/100 = 0.5
(20+5+25+10)/100 = 0.6
(20+5+25+10+15)/100 = 0.75
(20+5+25+10+15+5)/100 = 0.8
(20+5+25+10+15+5+10)/100 = 0.9
(20+5+25+10+15+5+10+10)/100 = 1.0
1.0
![Page 27: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/27.jpg)
Histogram Equalization Example (cont.)Histogram Equalization Example (cont.)
Intensity (r)
No. of Pixels(nj)
Acc Sum of Pr
Output value Quantized Output (s)
0 20 0.2 0.2x7 = 1.4 1
1 5 0.25 0.25*7 = 1.75 2
2 25 0.5 0.5*7 = 3.5 3
3 10 0.6 0.6*7 = 4.2 4
4 15 0.75 0.75*7 = 5.25 5
5 5 0.8 0.8*7 = 5.6 6
6 10 0.9 0.9*7 = 6.3 6
7 10 1.0 1.0x7 = 7 7
Total 100
![Page 28: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/28.jpg)
Histogram EqualizationHistogram Equalization
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 29: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/29.jpg)
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 30: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/30.jpg)
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 31: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/31.jpg)
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 32: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/32.jpg)
Histogram Equalization (cont.)Histogram Equalization (cont.)
Originalimage
After histogram equalization, the imagebecome a low contrast image
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 33: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/33.jpg)
Histogram MatchingHistogram Matching : Algorithm: Algorithm
r
r dwwprTs0
)()(
Concept : from Histogram equalization, we have
We get ps(s) = 1
We want an output image to have PDF pz(z)Apply histogram equalization to pz(z), we get
z
z duupzGv0
)()( We get pv(v) = 1
Since ps(s) = pv(v) = 1 therefore s and v are equivalent
Therefore, we can transform r to z by
r T( ) s G-1( ) z
To transform image histogram to be a desired histogram
![Page 34: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/34.jpg)
Histogram Matching : Algorithm (cont.)Histogram Matching : Algorithm (cont.)
s = T(r) v = G(z)
z = G-1(v)
1
2
3
4
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 35: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/35.jpg)
Histogram Matching ExampleHistogram Matching Example
Intensity( s )
# pixels
0 20
1 5
2 25
3 10
4 15
5 5
6 10
7 10
Total 100
Input imagehistogram
Intensity ( z )
# pixels
0 5
1 10
2 15
3 20
4 20
5 15
6 10
7 5
Total 100
Desired HistogramExample
User defineOriginaldata
![Page 36: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/36.jpg)
r (nj) Pr s
0 20 0.2 1
1 5 0.25 2
2 25 0.5 3
3 10 0.6 4
4 15 0.75 5
5 5 0.8 6
6 10 0.9 6
7 10 1.0 7
Histogram Matching Example Histogram Matching Example (cont.)(cont.)
1. Apply Histogram Equalization to both tables
z (nj) Pz v
0 5 0.05 0
1 10 0.15 1
2 15 0.3 2
3 20 0.5 4
4 20 0.7 5
5 15 0.85 6
6 10 0.95 7
7 5 1.0 7
sk = T(rk) vk = G(zk)
![Page 37: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/37.jpg)
r s
0 1
1 2
2 3
3 4
4 5
5 6
6 6
7 7
Histogram Matching Example Histogram Matching Example (cont.)(cont.)2. Get a map
v z
0 0
1 1
2 2
4 3
5 4
6 5
7 6
7 7
sk = T(rk) zk = G-1(vk)
r s v z
s v
We get
r z
0 1
1 2
2 2
3 3
4 4
5 5
6 5
7 6
z # Pixels
0 0
1 20
2 30
3 10
4 15
5 15
6 10
7 0
Actual Output Histogram
![Page 38: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/38.jpg)
Histogram Matching Example (cont.)Histogram Matching Example (cont.)
Desired histogram
Transfer function
Actual histogram
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 39: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/39.jpg)
Histogram Matching Example (cont.)Histogram Matching Example (cont.)
Originalimage
Afterhistogram
equalization
Afterhistogram matching
![Page 40: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/40.jpg)
Local Enhancement : Local Histogram EqualizationLocal Enhancement : Local Histogram Equalization
Concept: Perform histogram equalization in a small neighborhood
Orignal image After Hist Eq.After Local Hist Eq.In 7x7 neighborhood
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 41: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/41.jpg)
Local Enhancement : Local Enhancement : Histogram Statistic for Image EnhancementHistogram Statistic for Image Enhancement
We can use statistic parameters such as Mean, Variance of Local area for image enhancement
Image of tungsten filament taken usingAn electron microscope
In the lower right corner, there is afilament in the background which isvery dark and we want this to be brighter.
We cannot increase the brightness of the whole image since the white filament will be too bright.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 42: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/42.jpg)
Local EnhancementLocal EnhancementExample: Local enhancement for this task
otherwise ),(
and when),(),( 210
yxfMkDkMkmyxfE
yxg GsGGs xyxy
Original imageLocal Variance
image Multiplication
factor
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 43: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/43.jpg)
Local EnhancementLocal Enhancement
Output image
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 44: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/44.jpg)
Logic OperationsLogic Operations
AND
OR
Result Region of Interest
Image maskOriginalimage
Application:Crop areas of interest
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 45: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/45.jpg)
Arithmetic Operation: SubtractionArithmetic Operation: Subtraction
Error image
Application: Error measurement
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 46: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/46.jpg)
Arithmetic Operation: Subtraction (cont.)Arithmetic Operation: Subtraction (cont.)
Application: Mask mode radiography in angiography work
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 47: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/47.jpg)
Arithmetic Operation: Image AveragingArithmetic Operation: Image Averaging
Application : Noise reduction
),(),(1
yxyxg K
Averaging results in reduction of Noise variance
),(),(),( yxyxfyxg Degraded image
(noise)Image averaging
K
ii yxg
Kyxg
1
),(1),(
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 48: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/48.jpg)
Arithmetic Operation: Image Averaging (cont.)Arithmetic Operation: Image Averaging (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 49: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/49.jpg)
Sometime we need to manipulate values obtained from neighboring pixels
Example: How can we compute an average value of pixelsin a 3x3 region center at a pixel z?
44
676
1
92
2
2
7
5
2
26
4
4
5212
1
3
3
429
57
735 8222
Pixel z
Image
Basics of Spatial FilteringBasics of Spatial Filtering
![Page 50: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/50.jpg)
44
676
1
92
2
2
7
5
2
26
4
4
5212
1
3
3
429
57
735 8222
Pixel z
Step 1. Selected only needed pixels
467
69
1
3
3
4……
……
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 51: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/51.jpg)
467
69
1
3
3
4……
……
Step 2. Multiply every pixel by 1/9 and then sum up the values
1916
913
91
6917
919
91
4914
913
91
y
1 1
111
1111
91
X
Mask orWindow orTemplate
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 52: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/52.jpg)
Question: How to compute the 3x3 average values at every pixels?
44
676
1
92
2
2
7
5
2
26
4
4
5212
1
3
3
429
57
7
Solution: Imagine that we havea 3x3 window that can be placedeverywhere on the image
Masking Window
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 53: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/53.jpg)
4.3
Step 1: Move the window to the first location where we want to compute the average value and then select only pixels inside the window.
44
676
1
92
2
2
7
5
2
26
4
4
5212
1
3
3
429
57
7
Step 2: Computethe average value
3
1
3
1
),(91
i j
jipy
Sub image p
Original image
4 1
922
3297
Output image
Step 3: Place theresult at the pixelin the output image
Step 4: Move the window to the next location and go to Step 2
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 54: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/54.jpg)
The 3x3 averaging method is one example of the mask operation or Spatial filtering.
The mask operation has the corresponding mask (sometimes called window or template).
The mask contains coefficients to be multiplied with pixelvalues.
w(2,1) w(3,1)
w(3,3)
w(2,2)
w(3,2)
w(3,2)
w(1,1)
w(1,2)
w(3,1)
Mask coefficients
1 1
111
1111
91
Example : moving averaging
The mask of the 3x3 moving average filter has all coefficients = 1/9
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 55: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/55.jpg)
The mask operation at each point is performed by:1. Move the reference point (center) of mask to the location to be computed 2. Compute sum of products between mask coefficients and pixels in subimage under the mask.
p(2,1)
p(3,2)p(2,2)
p(2,3)
p(2,1)
p(3,3)
p(1,1)
p(1,3)
p(3,1)
……
……Subimage
w(2,1) w(3,1)
w(3,3)
w(2,2)
w(3,2)
w(3,2)
w(1,1)
w(1,2)
w(3,1)
Mask coefficients
N
i
M
j
jipjiwy1 1
),(),(
Mask frame
The reference pointof the mask
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 56: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/56.jpg)
The spatial filtering on the whole image is given by:
1. Move the mask over the image at each location.
2. Compute sum of products between the mask coefficeintsand pixels inside subimage under the mask.
3. Store the results at the corresponding pixels of the output image.
4. Move the mask to the next location and go to step 2until all pixel locations have been used.
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
![Page 57: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/57.jpg)
Examples of Spatial Filtering Masks
Examples of the masks
Sobel operators
0 1
100
2-1-2-1
-2 -1
102
0-101
xP
compute to
yP
compute to
1 1
111
1111
91
3x3 moving average filter
-1 -1
-18-1
-1-1-1-1
91
3x3 sharpening filter
![Page 58: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/58.jpg)
Smoothing Linear Filter : Moving AverageSmoothing Linear Filter : Moving Average
Application : noise reductionand image smoothing
Disadvantage: lose sharp details
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 59: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/59.jpg)
Smoothing Linear Filter (cont.)Smoothing Linear Filter (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 60: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/60.jpg)
Order-Statistic FiltersOrder-Statistic Filters
subimage
Original image
Moving window
Statistic parametersMean, Median, Mode, Min, Max, Etc.
Output image
![Page 61: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/61.jpg)
Order-Statistic Filters: Median FilterOrder-Statistic Filters: Median Filter
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 62: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/62.jpg)
Sharpening Spatial FiltersSharpening Spatial Filters
There are intensity discontinuities near object edges in an image
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 63: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/63.jpg)
Laplacian Sharpening : How it worksLaplacian Sharpening : How it works
20 40 60 80 100 120 140 160 180 2000
0.5
1
0 50 100 150 2000
0.1
0.2
0 50 100 150 200-0.05
0
0.05
Intensity profile
1st derivative
2nd derivative
p(x)
dxdp
2
2
dxpd
Edge
![Page 64: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/64.jpg)
0 50 100 150 200-0.5
0
0.5
1
1.5
0 50 100 150 200-0.5
0
0.5
1
1.5
Laplacian Sharpening : How it works (cont.)Laplacian Sharpening : How it works (cont.)
2
2
10)(dx
pdxp
Laplacian sharpening results in larger intensity discontinuity near the edge.
p(x)
![Page 65: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/65.jpg)
Laplacian Sharpening : How it works (cont.)Laplacian Sharpening : How it works (cont.)
2
2
10)(dx
pdxp
p(x)Before sharpening
After sharpening
![Page 66: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/66.jpg)
Laplacian MasksLaplacian Masks
-1 -1
-18-1
-1-1-1-1
-1 0
04-1
-10-10
1 1
1-81
1111
1 0
0-41
1010
Application: Enhance edge, line, pointDisadvantage: Enhance noise
Used for estimating image Laplacian 2
2
2
22
yP
xPP
or
The center of the mask is positive
The center of the mask is negative
![Page 67: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/67.jpg)
Laplacian Sharpening ExampleLaplacian Sharpening Example
p P2
P2 PP 2
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 68: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/68.jpg)
Laplacian Sharpening (cont.)Laplacian Sharpening (cont.)
PP 2Mask for
1 1
1-81
1111
-1 -1
-19-1
-1-1-1-1
-1 0
05-1
-10-10
1 0
0-41
1010
orMask for
P2
or
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 69: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/69.jpg)
Unsharp Masking and High-Boost FilteringUnsharp Masking and High-Boost Filtering
-1 -1
-1
k+8
-1
-1
-1
-1
-1
-1 0
0
k+4
-1
-1
0
-1
0
Equation:
),(),(),(),(
),(2
2
yxPyxkPyxPyxkP
yxPhbThe center of the mask is negative
The center of the mask is positive
![Page 70: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/70.jpg)
Unsharp Masking and High-Boost Filtering (cont.)Unsharp Masking and High-Boost Filtering (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 71: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/71.jpg)
First Order DerivativeFirst Order Derivative
20 40 60 80 100 120 140 160 180 2000
0.5
1
0 50 100 150 200-0.2
0
0.2
0 50 100 150 2000
0.1
0.2
Intensity profile
1st derivative
2nd derivative
p(x)
dxdp
dxdp
Edges
![Page 72: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/72.jpg)
First Order Partial Derivative:First Order Partial Derivative:Sobel operators
0 1
1
0
0
2
-1
-2
-1
-2 -1
1
0
2
0
-1
0
1xP
compute to y
P compute to
PxP
yP
![Page 73: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/73.jpg)
First Order Partial Derivative: Image GradientFirst Order Partial Derivative: Image Gradient
22
yP
xPP
Gradient magnitude
A gradient image emphasizes edges(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 74: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/74.jpg)
First Order Partial Derivative: Image GradientFirst Order Partial Derivative: Image Gradient
P
xP
yP
P
![Page 75: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/75.jpg)
Image Enhancement in the Spatial Domain : Image Enhancement in the Spatial Domain : Mix things up !
+ -
A
P2
Sharpening
P
smoothB
EC
D
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
![Page 76: Digital Image Processing Chapter 3: Image Enhancement in the Spatial Domain 15 June 2007](https://reader035.fdocuments.in/reader035/viewer/2022062316/568139f4550346895da1adca/html5/thumbnails/76.jpg)
EC
MultiplicationF
Image Enhancement in the Spatial Domain : Image Enhancement in the Spatial Domain : Mix things up !
A
G
H
PowerLaw Tr.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.