Digital Image Processing
(2nd Edition)
Rafael C. Gonzalez
Richard E.Woods
Dr Moe Moe Myint
Technological University (Kyaukse)
www.slideshare.net/MoeMoeMyint
moemoemyint@moemyanmar.ml
drmoemoemyint.blogspot.com
Miscellanea
 Lectures: Class A
 Monday 5-6
 Tuesday 6-7
 Lectures: Class B
 Monday 1-2
 Wednesday 5-6
 Labs:
 Tuesday for Class A and Wednesday for Class B
 Web Site:
 www.slideshare.net/MoeMoeMyint
 drmoemoemyint.blogspot.com
 E-mail: moemoemyint@moemyanmar.ml
2
Contents for Chapter 3
 This lecture will cover:
 Background
 Some Basic Gray Level Transformations
 Histogram Processing
 Enhancement Using Arithmetic/Logic Operations
 Basics of Spatial Filtering
 Smoothing Spatial Filters
 Sharpening Spatial Filters
 Combining Spatial Enhancement Methods
 Summary
3
Introduction
“It makes all the difference whether one sees darkness through
the light or brightness through the shadows”
David Lindsay
4
Preview
 The principal objective
to process an image so that the result is more suitable than the
original image for a specific application
The word specific is important because algorithms development for
enhancing X-ray images may not necessarily be the best approach
for enhancing pictures of Mars transmitted by a space probe.
5
Image enhancement example6
Two categories
 There is no general theory of image enhancement
 Spatial domain
image plane itself (the ‘natural’ image) and based on
direct manipulation of pixels in an image
 Frequency domain
based on modifying the Fourier transform of an image
(modify the image frequency components)
7
 No general theory
Image Enhancement
Enhancement
technique
Input image “Better”
image
Specific Application
Spatial Domain
Manipulate pixel intensity
directly
Frequency Domain
Modify the Fourier transform
8
x
y
Origin(0,0)
*(x,y)
x
y
Origin(0,0)
*(x,y)
Spatial coordinate system Cartesian coordinate system
g (x, y)=T [ f (x, y)]
Image Enhancement in Special Domain
The processed image Operator on f input image
9
Background
 Spatial domain processing
the aggregate of pixel composing an image procedures that
operate directly on these pixels
By expression: g(x, y)=T[ f(x, y) ]
Where f(x, y): input image
g(x, y): output (processed) image
T: operator on f
(Defined over some neighborhood of (x, y))
T
f(x,y) g(x,y)
10
The operator T can be defined over
a) The set of pixels (x, y) of the image
b) The set of ‘neighborhoods’ N(x, y) of each pixel
c) A set of images f1,f2,f3,…
a)
6 8 2 0
12 200 20 10
3 4 1 0
6 100 10 5
(Operator: Div. by 2)
11
b)
c)
6 8 2 0
12 200 20 10
226
6 8
12 200
(Operator: sum)
6 8 2 0
12 200 20 10
5 5 1 0
2 20 3 4
11 13 3 0
14 220 23 14
(Operator: sum)
12
Cont’d13
Defining the neighborhood
around (x, y)
Use a square/rectangle
subimage area that is
centered at (x, y)
Operation
Move the center of
the subimage from pixel
to pixel and apply
the operation T at
each location (x, y)
to compute the output
g(x, y)
 The easiest case of operators
When the neighborhood is 1 x 1(i.e, a single pixel) then g
depends only on the value of f at (x,y)
T becomes a gray-level transformation ( an intensity or
mapping) function:
s = T(r)
where;
r = gray-level at (x,y) in original image f(x,y)
s = gray-level at (x,y) in original image g(x,y)
This kind of processing is referred as point processing
 Point processing techniques (e.g., contrast stretching ,
thresholding)
Cont’d
14
Point processing
a) T(r) performs contrast stretching by producing an image of
higher contrast than the original by darkening the levels below
m and brightening the levels above m in the original image.
b) T(r ) produces a two-level (binary) image. (thresholding
function)
Contraststretching
thresholding
15
Contrast Stretching
Original Enhanced
16
 Thresholding transformations are particularly useful for
segmentation in which we want to isolate an object of interest
from a background.
Thresholding
Original Enhanced
s = 1.0 r > threshold
s = 0.0 r<= threshold
17
 If neighborhood is greater than 1 x 1,
 General approach: to use a function of the values of f in a
predefined neighborhood of (x, y) to determine the value of g
at (x, y).
The use of masks (or filters, kernels, template, or windows)
 a mask is a small (e.g., 3x3 ) 2-D array
 The values of mask coefficients
determine the nature of the process
(image sharpening)
Enhancement technique :
mask processing or filtering
Neighborhood Processing
18
Some Basic Gray Level Transformations
Gray–level transformation functions are among the simplest
of all image enhancement techniques
The values of pixels, before and after processing are related
by an expression s = T (r)
For an 8-bit environment, a lookup table will have 256
entries
Some basic gray level transformations functions:
Image Negatives
Log Transformations
Power-Law Transformations
Piecewise Transformation
oContrast Stretching
oGray-level Slicing
oBit-plane Slicing
19
Image Negatives
 The negative of an image with gray levels in the range [0, L-1]
is obtained by using the negative transformation which is
given by the expression
s = L – 1 – r
where; r is value of input pixel
s is value of processed pixel
input gray level ranges from 0 to L-1 ( [0, L-1] )
 Reversing the intensity level of image
 Suited for enhancing white or gray detail embedded in dark
regions of an image, especially when the black areas are
dominant in size
20
Image negatives
 Original Image : Digital Mammogram showing a small
lesion
 Much easier : to analyze the breast tissue in the negative
image
Original mammogram Negative image
Small
lesion
21
Some basic gray-level transformation functions used for
image enhancement
Linear:
Negative, Identity
Logarithmic:
Log, Inverse Log
Power-Law:
nth power, nth root
22
Log Transformation
 General form:
s = c log (1 + r )
where; c is a constant and r>=0
 Maps a narrow range of low gray-level values in the input
image into a wider range of output levels
 Use to expand the values of dark pixels in an image while
compressing the higher-level values
 The opposite is true of the inverse log transformation
 Compress the dynamic range of images with large variations in
pixel values
23
(a)Fourier spectrum with vales in the range 0 to 1.5x106
(b) Result of applying the log transformation with c = 1
If c = 1, values of result become 0 to 6.2
Log Transformation Example
s = log (1+r)
(a) (b)
24
 Basic form: s = c r γ
where; c and γ are positive constants
 To account for an offset (a measurable output when the input is
zero) :
s = c (r + ε )γ
 Power law is similar to
log when γ < 1 and similar
to inverse log when γ > 1
 Varying  obtains
family of possible
transformation curves
Power-Law Transformation
Figure: Plots of the equation s = c r γ for various
values of γ (c=1); γ = c = 1, identity
25
Power-Law Transformation Examples
 A variety of device used for image capture, printing and
display respond
 The power law equation is referred to as gamma
 The process used to correct power-law response is called
gamma correction
 Example:
Cathode ray tubes have
an intensity-to-voltage
response that is a power
function with exponent
varies from 1.8 to 2.5.
=2.5
=1/2.5
=2.5
(a) (b)
(c) (d)
26
Cont’d
 Also useful for general-
purpose contrast
manipulation
 Different curves highlight
different detail
  < 1
Expand dark gray levels
 = 0.6
 = 0.4  = 0.3
Figure : Magnetic
resonance (MR) image
27
Cont’d
>1
Expand light gray levels
 = 3
 = 5 = 4
28
Why power laws are popular?
 A cathode ray tube (CRT), for example, converts a video
signal to light in a nonlinear way. The light intensity I is
proportional to a power (γ) of the source voltage VS
 For a computer CRT, γ is about 2.2
 Viewing images properly on monitors requires γ-correction
29
 Advantage: the form of piecewise functions can be
arbitrarily complex
a practical implementation of some implementation of
some important transformations can be formulated only
as piece wise functions
 Disadvantage: specification requires considerably more
user input
 Contrast Stretching
 Gray-level slicing
 Bit-plane slicing
Piecewise-Linear Transformation Functions
30
 One of the simplest piecewise linear functions
 To increase the dynamic range of the gray levels in the image
being processed
 The locations of (r1,s1) and (r2,s2) control the shape of the
transformation function
 If r1= s1 and r2= s2 the transformation is a linear function
and produces no changes
 If r1=r2, s1=0 and s2=L-1, the transformation becomes a
thresholding function that creates a binary image
 Intermediate values of (r1,s1) and (r2,s2) produce various
degrees of spread in the gray levels of the output image,
thus affecting its contrast
Contrast Stretching
31
 Generally, r1≤r2 and s1≤s2
is assumed
to preserve the order of
gray levels
prevent the creation of
intensity artifacts in the
processed image
Cont’d
control point
32
Example of contrast stretching
Contrast stretching
8-bit image with
low contrast
Thresholding
33
 Highlight a specific range of gray levels in an image (e.g. to
enhance certain features)
 Tow basic approaches:
To display a high value for all
gray levels in the range of interest
and a low value for all other
gray levels (binary image)
Brightens the desired range of
gray levels but preserves
the background and gray-level
tonalities in the image
Gray-level slicing
34
Cont’d Highlight the major blood
vessels and study the shape of
the flow of the contrast
medium (to detect blockages,
etc.)
Measuring the actual flow of the
contrast medium as a function of
time in a series of images
35
Gray-level slicing
 Highlighting a specific range of gray levels
36
Bit-plane slicing
 Highlight the contribution made to total image appearance by specific bits
 Example: - each pixel is represented by 8 bits
- the image is composed of eight 1-bit planes
- plane 0 contains the least significant bit and
plane 7 contains the most significant bit.
 Plane 0 contains all the lowest order bits and plane 7 contains all the high-order bits
 Only the higher-order bits (especially the top four) contain the majority of the
visually significant data. The other bit planes contribute the more subtle details
 Is useful for analyzing the relative importance played by each bit of the image
 Determine the adequacy of the number of bits used to quantize each pixel
 Plane 7 corresponds exactly with an image thresholded at gray level 128
37
Bit-plane slicing
* Highlight specific bits
bit-planes of an image
(gray level 0~255)
Ex. 15010
1
0
0
1
0
1
0
0
38
10110011
1
1
0
0
1
1
0
1
Bit-plane 0
(least significant)
Bit-plane 7
(most significant)
39
7 6
5 4 3
2 1 0
For image
compression
An 8-bit fractal image
MSB
LSB
40
References
 “Digital Image Processing”, 2/ E, Rafael C. Gonzalez & Richard
E. Woods, www.prenhall.com/gonzalezwoods.
 Only Original Owner has full rights reserved for copied images.
 This PPT is only for fair academic use.
41
Chapter 3 – Next Section
(Coming Soon)
Questions?

Lect 03 - first portion

  • 1.
    Digital Image Processing (2ndEdition) Rafael C. Gonzalez Richard E.Woods Dr Moe Moe Myint Technological University (Kyaukse) www.slideshare.net/MoeMoeMyint moemoemyint@moemyanmar.ml drmoemoemyint.blogspot.com
  • 2.
    Miscellanea  Lectures: ClassA  Monday 5-6  Tuesday 6-7  Lectures: Class B  Monday 1-2  Wednesday 5-6  Labs:  Tuesday for Class A and Wednesday for Class B  Web Site:  www.slideshare.net/MoeMoeMyint  drmoemoemyint.blogspot.com  E-mail: moemoemyint@moemyanmar.ml 2
  • 3.
    Contents for Chapter3  This lecture will cover:  Background  Some Basic Gray Level Transformations  Histogram Processing  Enhancement Using Arithmetic/Logic Operations  Basics of Spatial Filtering  Smoothing Spatial Filters  Sharpening Spatial Filters  Combining Spatial Enhancement Methods  Summary 3
  • 4.
    Introduction “It makes allthe difference whether one sees darkness through the light or brightness through the shadows” David Lindsay 4
  • 5.
    Preview  The principalobjective to process an image so that the result is more suitable than the original image for a specific application The word specific is important because algorithms development for enhancing X-ray images may not necessarily be the best approach for enhancing pictures of Mars transmitted by a space probe. 5
  • 6.
  • 7.
    Two categories  Thereis no general theory of image enhancement  Spatial domain image plane itself (the ‘natural’ image) and based on direct manipulation of pixels in an image  Frequency domain based on modifying the Fourier transform of an image (modify the image frequency components) 7
  • 8.
     No generaltheory Image Enhancement Enhancement technique Input image “Better” image Specific Application Spatial Domain Manipulate pixel intensity directly Frequency Domain Modify the Fourier transform 8
  • 9.
    x y Origin(0,0) *(x,y) x y Origin(0,0) *(x,y) Spatial coordinate systemCartesian coordinate system g (x, y)=T [ f (x, y)] Image Enhancement in Special Domain The processed image Operator on f input image 9
  • 10.
    Background  Spatial domainprocessing the aggregate of pixel composing an image procedures that operate directly on these pixels By expression: g(x, y)=T[ f(x, y) ] Where f(x, y): input image g(x, y): output (processed) image T: operator on f (Defined over some neighborhood of (x, y)) T f(x,y) g(x,y) 10
  • 11.
    The operator Tcan be defined over a) The set of pixels (x, y) of the image b) The set of ‘neighborhoods’ N(x, y) of each pixel c) A set of images f1,f2,f3,… a) 6 8 2 0 12 200 20 10 3 4 1 0 6 100 10 5 (Operator: Div. by 2) 11
  • 12.
    b) c) 6 8 20 12 200 20 10 226 6 8 12 200 (Operator: sum) 6 8 2 0 12 200 20 10 5 5 1 0 2 20 3 4 11 13 3 0 14 220 23 14 (Operator: sum) 12
  • 13.
    Cont’d13 Defining the neighborhood around(x, y) Use a square/rectangle subimage area that is centered at (x, y) Operation Move the center of the subimage from pixel to pixel and apply the operation T at each location (x, y) to compute the output g(x, y)
  • 14.
     The easiestcase of operators When the neighborhood is 1 x 1(i.e, a single pixel) then g depends only on the value of f at (x,y) T becomes a gray-level transformation ( an intensity or mapping) function: s = T(r) where; r = gray-level at (x,y) in original image f(x,y) s = gray-level at (x,y) in original image g(x,y) This kind of processing is referred as point processing  Point processing techniques (e.g., contrast stretching , thresholding) Cont’d 14
  • 15.
    Point processing a) T(r)performs contrast stretching by producing an image of higher contrast than the original by darkening the levels below m and brightening the levels above m in the original image. b) T(r ) produces a two-level (binary) image. (thresholding function) Contraststretching thresholding 15
  • 16.
  • 17.
     Thresholding transformationsare particularly useful for segmentation in which we want to isolate an object of interest from a background. Thresholding Original Enhanced s = 1.0 r > threshold s = 0.0 r<= threshold 17
  • 18.
     If neighborhoodis greater than 1 x 1,  General approach: to use a function of the values of f in a predefined neighborhood of (x, y) to determine the value of g at (x, y). The use of masks (or filters, kernels, template, or windows)  a mask is a small (e.g., 3x3 ) 2-D array  The values of mask coefficients determine the nature of the process (image sharpening) Enhancement technique : mask processing or filtering Neighborhood Processing 18
  • 19.
    Some Basic GrayLevel Transformations Gray–level transformation functions are among the simplest of all image enhancement techniques The values of pixels, before and after processing are related by an expression s = T (r) For an 8-bit environment, a lookup table will have 256 entries Some basic gray level transformations functions: Image Negatives Log Transformations Power-Law Transformations Piecewise Transformation oContrast Stretching oGray-level Slicing oBit-plane Slicing 19
  • 20.
    Image Negatives  Thenegative of an image with gray levels in the range [0, L-1] is obtained by using the negative transformation which is given by the expression s = L – 1 – r where; r is value of input pixel s is value of processed pixel input gray level ranges from 0 to L-1 ( [0, L-1] )  Reversing the intensity level of image  Suited for enhancing white or gray detail embedded in dark regions of an image, especially when the black areas are dominant in size 20
  • 21.
    Image negatives  OriginalImage : Digital Mammogram showing a small lesion  Much easier : to analyze the breast tissue in the negative image Original mammogram Negative image Small lesion 21
  • 22.
    Some basic gray-leveltransformation functions used for image enhancement Linear: Negative, Identity Logarithmic: Log, Inverse Log Power-Law: nth power, nth root 22
  • 23.
    Log Transformation  Generalform: s = c log (1 + r ) where; c is a constant and r>=0  Maps a narrow range of low gray-level values in the input image into a wider range of output levels  Use to expand the values of dark pixels in an image while compressing the higher-level values  The opposite is true of the inverse log transformation  Compress the dynamic range of images with large variations in pixel values 23
  • 24.
    (a)Fourier spectrum withvales in the range 0 to 1.5x106 (b) Result of applying the log transformation with c = 1 If c = 1, values of result become 0 to 6.2 Log Transformation Example s = log (1+r) (a) (b) 24
  • 25.
     Basic form:s = c r γ where; c and γ are positive constants  To account for an offset (a measurable output when the input is zero) : s = c (r + ε )γ  Power law is similar to log when γ < 1 and similar to inverse log when γ > 1  Varying  obtains family of possible transformation curves Power-Law Transformation Figure: Plots of the equation s = c r γ for various values of γ (c=1); γ = c = 1, identity 25
  • 26.
    Power-Law Transformation Examples A variety of device used for image capture, printing and display respond  The power law equation is referred to as gamma  The process used to correct power-law response is called gamma correction  Example: Cathode ray tubes have an intensity-to-voltage response that is a power function with exponent varies from 1.8 to 2.5. =2.5 =1/2.5 =2.5 (a) (b) (c) (d) 26
  • 27.
    Cont’d  Also usefulfor general- purpose contrast manipulation  Different curves highlight different detail   < 1 Expand dark gray levels  = 0.6  = 0.4  = 0.3 Figure : Magnetic resonance (MR) image 27
  • 28.
    Cont’d >1 Expand light graylevels  = 3  = 5 = 4 28
  • 29.
    Why power lawsare popular?  A cathode ray tube (CRT), for example, converts a video signal to light in a nonlinear way. The light intensity I is proportional to a power (γ) of the source voltage VS  For a computer CRT, γ is about 2.2  Viewing images properly on monitors requires γ-correction 29
  • 30.
     Advantage: theform of piecewise functions can be arbitrarily complex a practical implementation of some implementation of some important transformations can be formulated only as piece wise functions  Disadvantage: specification requires considerably more user input  Contrast Stretching  Gray-level slicing  Bit-plane slicing Piecewise-Linear Transformation Functions 30
  • 31.
     One ofthe simplest piecewise linear functions  To increase the dynamic range of the gray levels in the image being processed  The locations of (r1,s1) and (r2,s2) control the shape of the transformation function  If r1= s1 and r2= s2 the transformation is a linear function and produces no changes  If r1=r2, s1=0 and s2=L-1, the transformation becomes a thresholding function that creates a binary image  Intermediate values of (r1,s1) and (r2,s2) produce various degrees of spread in the gray levels of the output image, thus affecting its contrast Contrast Stretching 31
  • 32.
     Generally, r1≤r2and s1≤s2 is assumed to preserve the order of gray levels prevent the creation of intensity artifacts in the processed image Cont’d control point 32
  • 33.
    Example of contraststretching Contrast stretching 8-bit image with low contrast Thresholding 33
  • 34.
     Highlight aspecific range of gray levels in an image (e.g. to enhance certain features)  Tow basic approaches: To display a high value for all gray levels in the range of interest and a low value for all other gray levels (binary image) Brightens the desired range of gray levels but preserves the background and gray-level tonalities in the image Gray-level slicing 34
  • 35.
    Cont’d Highlight themajor blood vessels and study the shape of the flow of the contrast medium (to detect blockages, etc.) Measuring the actual flow of the contrast medium as a function of time in a series of images 35
  • 36.
    Gray-level slicing  Highlightinga specific range of gray levels 36
  • 37.
    Bit-plane slicing  Highlightthe contribution made to total image appearance by specific bits  Example: - each pixel is represented by 8 bits - the image is composed of eight 1-bit planes - plane 0 contains the least significant bit and plane 7 contains the most significant bit.  Plane 0 contains all the lowest order bits and plane 7 contains all the high-order bits  Only the higher-order bits (especially the top four) contain the majority of the visually significant data. The other bit planes contribute the more subtle details  Is useful for analyzing the relative importance played by each bit of the image  Determine the adequacy of the number of bits used to quantize each pixel  Plane 7 corresponds exactly with an image thresholded at gray level 128 37
  • 38.
    Bit-plane slicing * Highlightspecific bits bit-planes of an image (gray level 0~255) Ex. 15010 1 0 0 1 0 1 0 0 38
  • 39.
  • 40.
    7 6 5 43 2 1 0 For image compression An 8-bit fractal image MSB LSB 40
  • 41.
    References  “Digital ImageProcessing”, 2/ E, Rafael C. Gonzalez & Richard E. Woods, www.prenhall.com/gonzalezwoods.  Only Original Owner has full rights reserved for copied images.  This PPT is only for fair academic use. 41
  • 42.
    Chapter 3 –Next Section (Coming Soon) Questions?