Chapter 3 PPT
Chapter 3 PPT
Chapter 3 PPT
What is DIP?
• Digital image processing deals with
manipulation of digital images through a
digital computer.
Other applications:
• Security: biometrics
• Medical Imaging
Intensity transformation
&
Spatial filtering
Spatial Domain processing:
• Intensity transformations:
Convert a given pixel value to a new pixel value based on some predefined function.
Averaging??
Padding?
Image Enhancement:
• Image Enhancement is process of
manipulating an image so that result is more
suitable than the original to a specific
application.
Basic intensity Transformation functions:
s = (L-1)-r
s cr
Where c and are positive constant.
Gamma correction:
• 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 1.8 to 2.5
• Viewing images properly on monitors requires
γ-correction
Piecewise –Linear Transformation:
• Contrast stretching
• Intensity level slicing
• Bit plane slicing
Contrast stretching:
• (r1,s1) and (r2,s2) controls
the shape of transformation.
• What if r1=r2,s1=0 and
s2=L-1 ??
• Its thresholding.
• What if (r1,s1)=(rmin,0)
and (r2,s2)=(rmax,L-1) ??
• Its contrast stretching.
x-axis – values of
intensities
y-axis – their
occurrence
Histogram:
x-axis – values of
intensities
y-axis – their
occurrence
Histogram:
• Histogram manipulation can be used for
image enhancement.
• Information inherent in histogram also is quite
useful in other image processing applications,
such as image compression and segmentation.
Histogram equalization:
• To improve the contrast of an image
• To transform an image in such a way that the
transformed image has a nearly uniform
distribution of pixel values
Histogram equalization:
Histogram Equalization:
• Intensity mapping form
s T (r ), 0 r L 1
Conditions:
a) T(r) is a monotonically increasing function in the
interval [0, L-1] and
b)
Histogram equalization:
Histogram Equalization:
In some formulations, we use the inverse in
which case
r T 1 (s), 0 s 1
(a) change to
a’) T(r) is a strictly monotonically increasing
function in the interval [0, L-1]
• Let pr(r) and ps(s) denote the PDFs of r and s
respectively
dr
p s ( s ) pr ( r )
ds
ps(sk)? ?
Histogram Equalization
Cumulative Histograms
Histogram Matching (Specification)
• Histogram Specification Procedure for discrete:
and round the resulting values to the integer range [0, L-1]
Histogram Matching (Specification)
Compute all values of the transformation function G
using same equation
q
G( zq ) ( L 1) pz (ri ), q 0,1,2,..., L 1
i 0
and round values of G
Histogram Matching (Specification)
For every value of sk, k = 0,1,…,L-1, use the stored
values of G to find the corresponding value of zq
so that G(zq) is closest to sk and store these
mappings from s to z.
G ( z1 ) 0.00 0 G ( z2 ) 0.00 0
G ( z3 ) 1.05 1 G ( z4 ) 2.45 2
G ( z5 ) 4.55 5 G ( z6 ) 5.95 6
G ( z7 ) 7.00 7
Example: Histogram Matching
rk
0
1
2
3
4
5
6
7
Example: Histogram Matching
Example: Histogram Matching
Example: Histogram Matching
Example: Histogram Matching
Example: Histogram Matching
Histogram Matching (Specification)
• Trial and error process
• No specific rules!!!
Local Histogram processing:
• Histogram Processing methods discussed in
the previous two sections are Global.
• What if it is necessary to enhance detail over
small areas in an image?
• This procedure is to define a neighborhood
and move its center pixel to pixel.
Local Histogram processing
• At each location, the histogram of the points
in the neighborhood is computed and either a
histogram equalization or histogram
specification transformation function is
obtained.
Local Histogram processing:
• Map the intensity of the pixel centered in the
neighborhood.
• Center of the neighborhood region is then
moved to an adjacent pixel location and the
procedure is repeated
• Sometimes to reduce computation is to utilize
non overlapping regions, but this method
usually produces an undesirable “blocky”
effect.
Local Histogram processing:
Statistics:
Statistics:
• Variance of numbers is defined as:
• Alternately :
Histogram statistics:
Pixel z
2 4 1 2 6 2
9 2 3 4 4 4
7 2 9 7 6 7
5 2 3 6 1 5
7 4 2 5 1 2
2 5 2 3 2 8
Image
Basics of Spatial Filtering (cont.)
2 4 1 2 6 2 1 1 1
y 3 4 4
9 2 3 4 4 4 9 9 9
1 1 1
7 2 9 7 6 7 1 1 1 1
X 1 1 1 9 7 6
5 2 3 6 1 5 9 9 9 9
1 1 1
1 1 1
7 4 2 5 1 2 3 6 1
Sub image 9 9 9
2 5 2 3 2 8
Question: How to compute the 3x3 average values at every pixels?
2 4 1 2 6 2 2 4 1 2 6 2 2 4 1 2 6 2
9 2 3 4 4 4 9 2 3 4 4 4 9 2 3 4 4 4
7 2 9 7 6 7 7 2 9 7 6 7 7 2 9 7 6 7
5 2 3 6 1 5 5 2 3 6 1 5 5 2 3 6 1 5
7 4 2 5 1 2 7 4 2 5 1 2 7 4 2 5 1 2
2 5 2 3 2 8 2 5 2 3 2 8 2 5 2 3 2 8
a b
g ( x, y ) w(s, t ) f ( x s, y t )
s a t b
a b
g ( x, y ) w(s, t ) f ( x s, y t )
s a t b
Vector representation of Linear
filtering:
3.4.4 Generating Spatial Filter Masks
• Gaussian function
x2 y 2
e 2
2
h ( x, y )
Non linear filter :
• It requires :
– Size of neighbor hood
– Operation performed
• Operations like max, min etc
Smoothing spatial filters:
• Linear spatial filters for smoothing:
averaging filters, lowpass filters
• Noise reduction
• Undesirable side effect: blur edges
Original n=3
n=9
n=5
n=35
n=15
Another Smoothing Example
By smoothing the original image we get rid of
lots of the finer detail which leaves only the
gross features for thresholding
f
( x) f ( x 1) f ( x) first-order derivative
x
f
( x 1) f ( x) f ( x 1)
x
2 f
f ( x 1) f ( x 1) 2 f ( x) second-order derivative
x 2
3.6.1 Foundation
f
( x) f ( x 1) f ( x) first-order derivative
x
f
( x 1) f ( x) f ( x 1)
x
2 f
f ( x 1) f ( x 1) 2 f ( x) second-order derivative
x 2
3.6.2 Use of Second Derivatives for Enhancement
2 f 2 f
f 2 2
2
2-D Laplacian operation
x y
2 f
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y) x-direction
x 2
2 f y-direction
f ( x, y 1) f ( x, y 1) 2 f ( x, y)
y 2
2 f ( x, y) [ f ( x 1, y) f ( x 1, y) f ( x, y 1) f ( x, y 1)] 4 f ( x, y)
0 1 0 1 1 1
1 -4 1 1 -8 1
0 1 0 1 1 1
Fig: a Fig: b
0 -1 0 -1 -1 -1
-1 4 -1 -1 8 -1
0 -1 0 -1 -1 -1
Fig: c Fig: d
3.6.2 Use of Second Derivatives for Enhancement
g ( x, y) f ( x, y) k gmask ( x, y)
(a)
(b) (c) (d)
Laplacian filter of Sharpened version
Sobel filter of bone
bone scan (a) of bone scan
scan (a)
achieved by
subtracting (a) and
(b)
Combining Spatial Enhancement Methods