You are on page 1of 39

Digital

Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Chapter 3 Image Enhancement in the


Spatial Domain
The principal objective of enhancement
to process an image so that the result is more suitable
than the original image for a specific application.

Enhancement methods
Spatial Domain (in this chapter)

based on direct manipulation of pixels in an image

Frequency Domain (in chapter 4)

based on modifying the Fourier transform of an image

The viewer is the ultimate judge of how well of


a particular method works.
2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Chapter 3 Image Enhancement in the


Spatial Domain

3.1 Background
3.2 Some basic gray level transformations
3.3 Histogram processing
3.4 Enhancement using arithmetic/logic operations
3.5 Basics of spatial filtering
3.6 Smoothing spatial filters
3.7 Sharpening spatial filters
3.8 Combining spatial enhancement methods
2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.1 Background
Spatial domain methods operate directly on
image pixels
g (x, y ) = T [ f (x, y )]

(3.1 - 1)

T operates only for one pixel

s = T (r )

(3.1 - 2)

Mapping
Contrast Stretching
Thresholding
Binary Image

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.1 Background

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.1 Background
T operates with neighboring pixels
Mask (filter, kernel, template, window)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.1 Background
m00
Mask = m10
m20

m01
m11
m21

m02
m12
m22

T [ f ( x, y )] = f ( x 1, y 1) m00 + f ( x 1, y ) m01 + f ( x 1, y + 1) m02 +


f ( x, y 1) m10 + f ( x, y ) m11 + f ( x, y + 1) m12 +

f ( x + 1, y 1) m20 + f ( x + 1, y ) m21 + f ( x + 1, y + 1) m22

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.1 Background

Original

1
9
Mask = 1
9
Image 19

1
1
1

9
9
9

1
9
1
9
1
9

Processed Image

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Image Negative

s = (L 1) r

(3.2 - 1)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Original Image

Processed Image

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Log Transformation

s = c log(1 + r )

(3.2 - 2)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Log Transformation

Original Image

Processed Image

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Power-Law Transformation

s = cr

(3.2 - 3)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Power-Law Transformation

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Power-Law Transformation

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Power-Law Transformation

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions
Contrast Stretching

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions

Original Image

Processed Image

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions
Gray-level slicing

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions

Original Image

Processed Image

2002 R. C. Gonzalez & R. E. Woods

10

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions
Bit-plane slicing

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.2 Some basic gray level transformations


Piecewise-Linear Transformation Functions

2002 R. C. Gonzalez & R. E. Woods

11

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


h(rk ) = nk

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing

2002 R. C. Gonzalez & R. E. Woods

12

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization

Transformation Function

s = T (r )

0 r 1

(3.3 - 1)

Conditions:
(a) T(r) is single valued and
monotonically increasing
(b) 0 T(r) 1 for 0 r 1

Inverse function

r = T 1 (s )

0 s 1

(3.3 - 2)

*(a)(b)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization

PDFs() of r and s

r pr

(r )

sps

(s ) = pr (r ) dr

ds

(3.3 - 3)

s3.3-1s
r

2002 R. C. Gonzalez & R. E. Woods

13

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization
If s is the Cumulative Density Function (CDF) of pr

*(a)(b)

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization

ps (s ) = pr (r )

2002 R. C. Gonzalez & R. E. Woods

dr
ds

ps(s) is a uniform PDF


Because ps(s) is 1 for any pr(r)

14

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization

Discrete Version

rk = k, nk rk

0 sk 1

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Equalization

Histogram Equalization
to produce an output image that has a uniform
histogram

procedures
Histogram

CDF()T()
T()

2002 R. C. Gonzalez & R. E. Woods

15

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

2002 R. C. Gonzalez & R. E. Woods

2002 R. C. Gonzalez & R. E. Woods

16

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

2002 R. C. Gonzalez & R. E. Woods

3.3 Histogram Processing


Histogram Matching (Specification)

Development of the method


r
z
T( ): r -> s
G( ): z->s

2002 R. C. Gonzalez & R. E. Woods

17

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Matching (Specification)

Discrete Version

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Matching (Specification)

2002 R. C. Gonzalez & R. E. Woods

18

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Histogram Matching (Specification)

Implementation
1.Histogram
2.(3.3-13) sk
3.(3.3-14)pz(z)G
4.(3.3-17) zk
5.2-4
rk sk
skzk

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Comparison between histogram


equalization and histogram matching

2002 R. C. Gonzalez & R. E. Woods

19

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

2002 R. C. Gonzalez & R. E. Woods

2002 R. C. Gonzalez & R. E. Woods

20

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Local Enhancement
:1.
2.
2.1.histogram
2.2.histogram equalization/matching

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Use of histogram statistice for image enhancement


N-Norm
mean value
2-Norm
Standard Deviation

Sx,y

2002 R. C. Gonzalez & R. E. Woods

21

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Use of histogram statistice for image enhancement

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Use of histogram statistice for image enhancement
Block Size = 3x3

2002 R. C. Gonzalez & R. E. Woods

22

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.3 Histogram Processing


Use of histogram statistice for image enhancement

E=4.0, k0=0.4, k1=0.02, k2=0.4


2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations
performed on a pixel by pixel basis between two or
more images
Logic Operations

AND
OR
NOT

Arithmetic Operations
Substraction
Averaging

2002 R. C. Gonzalez & R. E. Woods

23

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations
Image Substraction

2002 R. C. Gonzalez & R. E. Woods

24

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations
= +

2002 R. C. Gonzalez & R. E. Woods

25

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations - Image averaging

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.4 Enhancement using Arithmetic/Logic


Operations - Image averaging

2002 R. C. Gonzalez & R. E. Woods

26

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.5 Basics of spatial filtering


Mask
filter, kernel, templete, window

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.5 Basics of spatial filtering


Mask
filter, kernel, templete, window
converlution mask/kernel

2002 R. C. Gonzalez & R. E. Woods

27

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Smoothing filters are used for
blurring
noise reduction

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Smoothing Linear Filters
Smoothing linear filters
also called
averaging filter
lowpass filter

2002 R. C. Gonzalez & R. E. Woods

28

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Smoothing Linear Filters
Mask

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Smoothing Linear Filters

2002 R. C. Gonzalez & R. E. Woods

29

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Order-Statistics Filters
Non-linear filters
Median filter
example
unsorted (60,20,15,23,35,47,78,53,65)
sorted (15,20,23,35,47
,53,60,65,78)
(15,20,23,35,47,53,60,65,78)
the median is 47

Max filter
Min filter

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.6 Smoothing Spatial Filter


Order-Statistics Filters

2002 R. C. Gonzalez & R. E. Woods

30

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Sharpening Spatial filters are used to
highlight fine detail
enhance detail that has been blurred

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Foundation
First-order derivative

Second-order derivative

2002 R. C. Gonzalez & R. E. Woods

31

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Foundation

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement
The Laplacian
Development of the method

2002 R. C. Gonzalez & R. E. Woods

32

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement
Filters

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

33

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement
Simplification

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

34

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement
Unsharp masking and high-boost filtering

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

35

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of second Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of First Derivatives for enhancement
The Gradient ()

2002 R. C. Gonzalez & R. E. Woods

36

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of First Derivatives for enhancement
for 3 x 3 masks

(b) and (c) are refered as


Roberts cross-gradient Operators

(d) and (e) are called


Sobel Operators

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of First Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

37

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of First Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.7 Sharpening Spatial Filters


Use of First Derivatives for enhancement

2002 R. C. Gonzalez & R. E. Woods

38

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.8 Combining Spatial Enhancement


Methods

2002 R. C. Gonzalez & R. E. Woods

Digital
Digital Image
Image Processing,
Processing, 2nd
2nd ed.
ed.

www.imageprocessingbook.com

3.8 Combining Spatial Enhancement


Methods

2002 R. C. Gonzalez & R. E. Woods

39

You might also like