1
BIM472 Image Processing
Processing in Spatial Domain
Part 1. Intensity Transformations
BIM472 Image Processing 2Processing in Spatial Domain - Intensity Transformations
Outline
• Spatial Domain vs. Transform Domain
• Spatial Domain Processing
• Intensity Transformations
– Image Negative
– Log Transformation
– Power-Law (Gamma) Transformation
• Piecewise-Linear Transformations
– Contrast Streching
– Intensity Level Slicing
– Bit-plane Slicing
• Histogram Processing
– Histogram Equalization
– Histogram Matching
• Matlab Functions
2
BIM472 Image Processing 3Processing in Spatial Domain - Intensity Transformations
Spatial domain:
• Spatial domain refers to image plane itself
• Processing in spatial domain indicates direct manipulation
of pixels (intensity values ) in an image.
Transform domain:
• Image is first transformed into another domain (using FFT,
DCT, etc.).
• Processing in transform domain indicates manipulation of
transform coefficients, not the intensity values, of the image.
Spatial Domain vs. Transform Domain
BIM472 Image Processing 4Processing in Spatial Domain - Intensity Transformations
Spatial domain processing is divided into two categories:
• Intensity transformation (point processing) : operates on
single pixels of an image, principally for the purpose of
contrast manipulation and image thresholding
• Spatial filtering: operates in a neigborhood of every pixel in
an image for performing image enhancement (i.e.,
sharpening, etc.).
Spatial Domain Processing
3
BIM472 Image Processing 5Processing in Spatial Domain - Intensity Transformations
( , ) [ ( , )])
( , ) : input image
( , ) : output image
: an operator on defined over
a neighborhood of point ( , )
g x y T f x y
f x y
g x y
T f
x y
=
Spatial Domain Processing
BIM472 Image Processing 6Processing in Spatial Domain - Intensity Transformations
Spatial Domain Processing
1x1 neighborhood = Intensity Transformation
4
BIM472 Image Processing 7Processing in Spatial Domain - Intensity Transformations
Spatial Domain Processing
BIM472 Image Processing 8Processing in Spatial Domain - Intensity Transformations
Intensity transformation function
( )s T r=
Intensity Transformation
5
BIM472 Image Processing 9Processing in Spatial Domain - Intensity Transformations
Intensity Transformation
BIM472 Image Processing 10Processing in Spatial Domain - Intensity Transformations
Image negatives
1s L r= − −
Image Negative
6
BIM472 Image Processing 11Processing in Spatial Domain - Intensity Transformations
Small lesion
Image Negative
BIM472 Image Processing 12Processing in Spatial Domain - Intensity Transformations
Log Transformations
log(1 )s c r= +
Log Transformation
7
BIM472 Image Processing 13Processing in Spatial Domain - Intensity Transformations
Log Transformation
BIM472 Image Processing 14Processing in Spatial Domain - Intensity Transformations
Power-Law (Gamma)
Transformations
s crγ=
Power-Law (Gamma) Transformation
8
BIM472 Image Processing 15Processing in Spatial Domain - Intensity Transformations
Example: Gamma Transformations
Power-Law (Gamma) Transformation
BIM472 Image Processing 16Processing in Spatial Domain - Intensity Transformations
Example: Gamma Transformations
Power-Law (Gamma) Transformation
9
BIM472 Image Processing 17Processing in Spatial Domain - Intensity Transformations
• Contrast Stretching
– Contrast is the difference in visual properties that makes an object
distinguishable from other objects and the background.
– Contrast stretching expands the range of intensity levels in an image
so that it spans the full intensity range of the recording medium or
display device.
• Intensity-level Slicing
– Highlighting a specific range of intensities in an image often is of
interest.
Piecewise-Linear Transformations
BIM472 Image Processing 18Processing in Spatial Domain - Intensity Transformations
Contrast Stretching
10
BIM472 Image Processing 19Processing in Spatial Domain - Intensity Transformations
Highlight the major blood vessels and study the shape of 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
Intensity Level Slicing
BIM472 Image Processing 20Processing in Spatial Domain - Intensity Transformations
Bit Plane Slicing
11
BIM472 Image Processing 21Processing in Spatial Domain - Intensity Transformations
Bit Plane Slicing
BIM472 Image Processing 22Processing in Spatial Domain - Intensity Transformations
• The values of the 8th bit are 0 for byte values [0,127] and 1
for [128,255].
• The 7th bit plane outputs a 0 for byte values in the range [0,
63], a 1 for byte values in the range [64, 127], a 0 for byte
values in the range [128, 191], and a 1 for byte values in the
range [192, 255].
• and so on...
Bit Plane Slicing
12
BIM472 Image Processing 23Processing in Spatial Domain - Intensity Transformations
Bit Plane Slicing
Original image is reconstructed using formula below:
Image = 2*(2*(2*(2*(2*(2*(2*b7+b6)+b5)+b4)+b3)+b2)+b1)+b0;
BIM472 Image Processing 24Processing in Spatial Domain - Intensity Transformations
• Histogram Equalization
• Histogram Matching
Histogram Processing
13
BIM472 Image Processing 25Processing in Spatial Domain - Intensity Transformations
• Histogram is a graph indicating the number of times each
grey level occurs in the image.
• p(rk) is an estimate of the probability of occurence of
intensity level rk in an image. Sum of all components is
equal to 1.
Histogram Processing
Histogram ( )
is the intensity value
is the number of pixels in the image with intensity
k k
th
k
k k
h r n
r k
n r
=
Normalized histogram ( )
: the number of pixels in the image of
size M N with intensity
kk
k
k
np r
MN
n
r
=
×
BIM472 Image Processing 26Processing in Spatial Domain - Intensity Transformations
We can gather a great deal about the appearance of an image
from its histogram, as the following examples indicate.
• In a dark image, the grey levels (and hence the histogram)
would be clustered at the lower end.
• In a uniformly bright image, the grey levels would be
clustered at the upper end.
• In a well contrasted image, the grey levels would be well
spread out over much of the range.
Histogram Processing
14
BIM472 Image Processing 27Processing in Spatial Domain - Intensity Transformations
Histogram Processing
BIM472 Image Processing 28Processing in Spatial Domain - Intensity Transformations
Histogram Equalization
• Histogram equalization is a method for contrast adjustment using
the histogram of the image.
• In other words, it produces a uniform histogram
• Transformation function (continuous) that produce an output intensity
level s for every pixel in the input image having intensity r :
w is a dummy variable of integration
p(w) represents the probability density function (PDF)
L is the maximum intensity level
0( ) ( 1) ( )
r
rs T r L p w dw= = − ∫
15
BIM472 Image Processing 29Processing in Spatial Domain - Intensity Transformations
( ) 0 1s T r r L= ≤ ≤ −. T(r) is a strictly monotonically increasing function
in the interval 0 -1;
. 0 ( ) -1 for 0 -1.
a
r L
b T r L r L
≤ ≤
≤ ≤ ≤ ≤
Histogram Equalization
• Assumptions on transformation function:
BIM472 Image Processing 30Processing in Spatial Domain - Intensity Transformations
Example
2
Suppose that the (continuous) intensity values
in an image have the PDF
2, for 0 r L-1
( 1)( )
0, otherwise
Find the transformation function for equalizing
the image histogra
r
r
Lp r
≤ ≤ −=
m.
Histogram Equalization
16
BIM472 Image Processing 31Processing in Spatial Domain - Intensity Transformations
Example
0( ) ( 1) ( )
r
rs T r L p w dw= = − ∫20
2( 1)
( 1)
r wL dw
L= −
−∫2
1
r
L=
−
Histogram Equalization
BIM472 Image Processing 32Processing in Spatial Domain - Intensity Transformations
0
Continuous case:
( ) ( 1) ( )r
rs T r L p w dw= = − ∫
0
Discrete values:
( ) ( 1) ( )k
k k r j
j
s T r L p r=
= = − ∑
0 0
1( 1) k=0,1,..., L-1
k kj
j
j j
n LL n
MN MN= =
−= − =∑ ∑
Histogram Equalization
17
BIM472 Image Processing 33Processing in Spatial Domain - Intensity Transformations
Example:
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution shown in following table. Get the histogram equalization transformation function and give the ps(sk) for each sk.
Histogram Equalization
BIM472 Image Processing 34Processing in Spatial Domain - Intensity Transformations
0
0 0
0
( ) 7 ( ) 7 0.19 1.33r j
j
s T r p r=
= = = × =∑ 1→1
1 1
0
( ) 7 ( ) 7 (0.19 0.25) 3.08r j
j
s T r p r=
= = = × + =∑ 3→
2 3
4 5
6 7
4.55 5 5.67 6
6.23 6 6.65 7
6.86 7 7.00 7
s s
s s
s s
= → = →
= → = →
= → = →
Histogram Equalization
18
BIM472 Image Processing 35Processing in Spatial Domain - Intensity Transformations
• New histogram values:
– s0 : 790 / 4096
– s1 : 1023 / 4096
– s2 : 850 / 4096
– s3, s4 : (656 + 329) / 4096
– s5, s6, s7 : (245+122+81) / 4096
Histogram Equalization
BIM472 Image Processing 36Processing in Spatial Domain - Intensity Transformations
Histogram Equalization
19
BIM472 Image Processing 37Processing in Spatial Domain - Intensity Transformations
Histogram Equalization
BIM472 Image Processing 38Processing in Spatial Domain - Intensity Transformations
• Histogram matching (histogram specification) generate a processed image that has a specified histogram
• Obtain pr(rj) from the input image and then obtain the values of sk, round the value to the integer range [0, L-1].
• Use the specified PDF and obtain the transformation function G(zq), round the value to the integer range [0, L-1].
• Mapping from sk to zq
0 0
( 1)( ) ( 1) ( )
k k
k k r j j
j j
Ls T r L p r n
MN= =
−= = − =∑ ∑
0
( ) ( 1) ( )q
q z i k
i
G z L p z s=
= − =∑1( )q kz G s−=
Histogram Matching
20
BIM472 Image Processing 39Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution shown in the following table (on the left). Get the histogram transformation function and make the output image with the specified histogram, listed in the table on the right.
Histogram Matching
BIM472 Image Processing 40Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Obtain the scaled histogram-equalized values,
Compute all the values of the transformation function G,
0 1 2 3 4
5 6 7
1, 3, 5, 6, 7,
7, 7, 7.
s s s s s
s s s
= = = = =
= = =
0
0
0
( ) 7 ( ) 0.00z j
j
G z p z=
= =∑
1 2
3 4
5 6
7
( ) 0.00 ( ) 0.00
( ) 1.05 ( ) 2.45
( ) 4.55 ( ) 5.95
( ) 7.00
G z G z
G z G z
G z G z
G z
= =
= =
= =
=
0→
0→ 0→1→ 2→
6→5→
7→
Histogram Matching
21
BIM472 Image Processing 41Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Histogram Matching
BIM472 Image Processing 42Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Obtain the scaled histogram-equalized values,
Compute all the values of the transformation function G,
0 1 2 3 4
5 6 7
1, 3, 5, 6, 7,
7, 7, 7.
s s s s s
s s s
= = = = =
= = =
0
0
0
( ) 7 ( ) 0.00z j
j
G z p z=
= =∑
1 2
3 4
5 6
7
( ) 0.00 ( ) 0.00
( ) 1.05 ( ) 2.45
( ) 4.55 ( ) 5.95
( ) 7.00
G z G z
G z G z
G z G z
G z
= =
= =
= =
=
0→
0→ 0→1→ 2→
6→5→
7→
s0
s2 s3
s5 s6 s7
s1
s4
Histogram Matching
22
BIM472 Image Processing 43Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
0 1 2 3 4
5 6 7
1, 3, 5, 6, 7,
7, 7, 7.
s s s s s
s s s
= = = = =
= = =
0
1
2
3
4
5
6
7
kr
Histogram Matching
BIM472 Image Processing 44Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
0 3
1 4
2 5
3 6
4 7
5 7
6 7
7 7
k qr z→
→
→
→
→
→
→
→
→
Histogram Matching
23
BIM472 Image Processing 45Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Histogram Matching
BIM472 Image Processing 46Processing in Spatial Domain - Intensity Transformations
Example: Histogram Matching
Histogram Matching
24
BIM472 Image Processing 47Processing in Spatial Domain - Intensity Transformations
Histogram Matching
BIM472 Image Processing 48Processing in Spatial Domain - Intensity Transformations
Matlab Functions
• Image arithmetic.– imadd - Add two images or add constant to image.
– imsubtract - Subtract two images or subtract constant from image.
– imlincomb - Linear combination of images.
– imcomplement - Complement image (negative)
• Spatial transformations.– imresize - Resize image.
– imrotate - Rotate image.
– imadjust - Adjust image intensity values
• Histogram operations– imhist - Display histogram of image data.
– histeq - Enhance contrast using histogram equalization.
25
BIM472 Image Processing 49Processing in Spatial Domain - Intensity Transformations
Summary
• Spatial Domain vs. Transform Domain
• Spatial Domain Processing
• Intensity Transformations
– Image Negative
– Log Transformation
– Power-Law (Gamma) Transformation
• Piecewise-Linear Transformations
– Contrast Streching
– Intensity Level Slicing
– Bit-plane Slicing
• Histogram Processing
– Histogram Equalization
– Histogram Matching
• Matlab Functions
BIM472 Image Processing 50Processing in Spatial Domain - Intensity Transformations
References
• “Digital Image Processing, 3/E”, R. C. Gonzalez & R. E.
Woods, Prentice Hall.
• “Lecture Notes”, Frank (Qingzhong) Liu, University of New
Mexico Tech.
• “Lecture Notes”, Richard Alan Peters, Vanderbilt University.
Top Related