CHP 3 Image Enhancement in The Spatial Domain 1 Min
CHP 3 Image Enhancement in The Spatial Domain 1 Min
3
IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN
Unit structure :
3.0 Objectives
3.1 Introduction
3.2 Basic Grey Level Transform
3.3 Identity Transform Function
3.4 Image Negatives
3.5 Logarithmic Functions
3.6 Power-Law Functions
3.7 Piecewise-Linear Transformation Functions
3.8 Image Contrast Stretching
3.9 Image Thresholding
3.10 Gray-level Slicing
3.11 Bit-plane Slicing
3.12 Basics of Histogram Processing
3.13 Histogram equalisation (Automatic)
3.14 Histogram matching (specification)
3.15 Local histogram equalisation
3.16 Enhancement using Arithmetic/ Logic Operation
3.16.1 Image Subtraction
3.16.2 Image Averaging
3.17 Summary
3.18 Unit end exercise
3.19 Further Reading
3.0 OBJECTIVES
www.rocktheit.com www.facebook.com/rocktheit
2 Image Enhancement in the Spatial Domain
Spatial domain refers to the image plane itself, and approaches in this category are based
on direct manipulation of pixels in an image.
Frequency domain processing techniques are based on modifying the Fourier transform of
the image.
Suppose we have a digital image which can be represented by a two dimensional random
field f ( x, y ) .
Spatial domain processes will be denoted by the expression
g ( x, y) [ T= ] or s=T(r)
The value of pixels, before and after processing, will be denoted by r and s, respectively.
Where f(x, y) is the input to the image, g(x, y) is the processed image and T is an operator
on f.
The operator T applied on f ( x, y ) may be defined over:
(i) A single pixel ( x , y ) . In this case T is a grey level transformation (or mapping)
function.
(ii) Some neighborhood of ( x , y ) .
(iii) T may operate to a set of input images instead of a single image.
We are dealing now with image processing methods that are based only on the intensity
of single pixels.
Consider the following figure, which shows three basic types of functions used frequently
for image enhancement:
www.rocktheit.com www.facebook.com/rocktheit
3 Image Enhancement in the Spatial Domain
Figure 3.1 : Some of the basic grey level transformation functions used for image
enhancement
The three basic types of functions used frequently for image enhancement:
1. Linear Functions:
Identity Transformation
Negative Transformation
Contrast Stretching
Thresholding
2. Logarithmic Functions:
Log Transformation
Inverse-log Transformation
3. Power-Law Functions:
nth power transformation
nth root transformation
www.rocktheit.com www.facebook.com/rocktheit
4 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
5 Image Enhancement in the Spatial Domain
The idea is that the intensity of the output image decreases as the intensity of the input
increases.
This is useful in numerous applications such as displaying medical images.
3.5
Q ] Obtain the digital negative image of the 3 Bit image as shown below:
1 2 2 2 2
3 2 4 5 2
2 6 6 7 0
www.rocktheit.com www.facebook.com/rocktheit
6 Image Enhancement in the Spatial Domain
2 6 6 5 1
0 2 3 2 1
Solution:
For obtaining the negative image :
f2( x,y ) =L – 1 – f1(x,y )
Where ,
L : Total No. of Gray Levels
f1(x,y ) : Original Image.
f1(x,y )
Resultant image f2( x,y )
Log Transformation
www.rocktheit.com www.facebook.com/rocktheit
7 Image Enhancement in the Spatial Domain
S = C log (r + 1)
www.rocktheit.com www.facebook.com/rocktheit
8 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
9 Image Enhancement in the Spatial Domain
The process used to correct this power-law response phenomena is called a gamma
correction.
Gamma correction matters if you have any interest in displaying an image accurately on a
computer screen.
Images which are not properly corrected can look either bleached out (very small value of
) , or too dark (very large value of ).
Varying the amount of gamma correction changes not only the brightness, but also the
ratios of red to green to blue.
Almost every computer monitor, from whatever manufacturer, has one thing in common.
They all have a intensity to voltage response curve which is roughly a 2.5 power function.
This just means that if you send your computer monitor a message that a certain pixel
should have intensity equal to x, it will actually display a pixel which has intensity equal to x
www.rocktheit.com www.facebook.com/rocktheit
10 Image Enhancement in the Spatial Domain
^ 2.5 Because the range of voltages sent to the monitor is between 0 and 1, this means that
the intensity value displayed will be less than what you wanted it to be. (0.5 ^ 2.5 = 0.177
for example) Monitors, then, are said to have a gamma of 2.5.
www.rocktheit.com www.facebook.com/rocktheit
11 Image Enhancement in the Spatial Domain
Principle Disadvantage: Their specification requires more user input that previous
transformations
Contrast Stretching
Gray-level Slicing
Bit-plane slicing
www.rocktheit.com www.facebook.com/rocktheit
12 Image Enhancement in the Spatial Domain
bc
Pout Pin c a
d c
Values below 0 are set to 0 and values about 255 are set to 255.
The problem with this is that a single outlying pixel with either a very high or very low value
can severely affect the value of c or d and this could lead to very unrepresentative scaling.
www.rocktheit.com www.facebook.com/rocktheit
13 Image Enhancement in the Spatial Domain
Figure 3.10(c) (above image) shows the result of contrast stretching, obtained by setting
(r1, s1) = (rmin, 0) and (r2, s2) = (rmax,L-1) where rmin and rmaxdenote the minimum and
maximum gray levels in the image, respectively.
Thus, the transformation function stretched the levels linearly from their original range to
the full range [0,L-1].
Finally, Figure 3.10(d) (above image) shows the result of using the thresholding function
defined previously, with r1=r2=m, the mean gray level in the image.
In many vision applications, it is useful to be able to separate out the regions of the image
corresponding to objects in which we are interested, from the regions of the image that
correspond to background.
www.rocktheit.com www.facebook.com/rocktheit
14 Image Enhancement in the Spatial Domain
Thres holding provides a way to perform this segmentation on the basis of the different
intensities or colors in the foreground and background regions of an image.
In addition, it is also useful to be able to see what areas of an image consist of pixels
whose values lie within a specified range.
Black pixels correspond to background and white pixels correspond to foreground (or vice
versa).
In a 8 bit grey scale image, If the pixel's intensity is higher than the threshold, the pixel is
set to white ie. 255 in the output.
Above, Figure 3.10(a) shows a typical transformation used for contrast stretching.
The locations of points (r1, s1) and (r2, s2) control the shape of the transformation function.
www.rocktheit.com www.facebook.com/rocktheit
15 Image Enhancement in the Spatial Domain
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.
Q] Obtain the Threshold image for the 3 Bit image shown below.
Choose appropriate threshold value T.
Solution:
To get an appropriate threshold value T we first obtain a frequency table and plot the
gray level histogram of the image.
www.rocktheit.com www.facebook.com/rocktheit
16 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
17 Image Enhancement in the Spatial Domain
This technique is used to highlight a specific range of gray levels in a given image.
It can be implemented in several ways, but the two basic themes are:
One approach is to display a high value for all gray levels in the range of interest and allow
value for all other gray levels.
This transformation, shown in Fig 3.11 (a), (figure 3.8) produces abinary image.
The second approach, based on the transformation shown in Fig 3.11 (b), (figure 3.8)
brightens the desired range of gray levels but preserves gray levels unchanged.
Fig 3.11 (c) (figure 3.8) shows a gray scale image, and
Fig 3.11 (d) (figure 3.8) shows the result of using the transformation in Fig 3.11 (a).
www.rocktheit.com www.facebook.com/rocktheit
18 Image Enhancement in the Spatial Domain
Figure 3.9 : Gray Level slicing without background and with back ground
1. With Background
2. Without Background
Q] Perform gray level slicing with Background and Without Background on the 3 bit
image shown below. ( Assume r1 =2 and r2= 4 ).
www.rocktheit.com www.facebook.com/rocktheit
19 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
20 Image Enhancement in the Spatial Domain
Plane 0 contains the least significant bit and plane 7 contains the most significant bit.
In terms of 8-bits bytes, plane 0 contains all lowest order bits in the bytes comprising the
pixels in the image and plane 7 contains all high order bits.
Instead of highlighting gray-level range, we couldhighlight the contribution made by each bit
Only the higher order bits (top four) contain visually significant data.
www.rocktheit.com www.facebook.com/rocktheit
21 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
22 Image Enhancement in the Spatial Domain
FIGURE 3.12 The eight bit planes of the image in Fig. 3.11. The number at the bottom,
right of each image identifies the bit plane.
3.12 BASICS OF HISTOGRAM PROCESSING
The histogram of a digital image with gray levels in the range [0, L-1] is a discrete function
of the form
H(rk)=nk
where rk is the kth gray level and nk is the number of pixels in the image having the level
rk.
A normalized histogram is given by the equation
p(rk)=nk/n for k=0,1,2,…..,L-1
P(rk) gives the estimate of the probability of occurrence of gray level rk.
The sum of all components of a normalized histogram is equal to 1.
www.rocktheit.com www.facebook.com/rocktheit
23 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
24 Image Enhancement in the Spatial Domain
The components of the histogram in the high contrast image cover a broad range of the
gray scale.
The net effect of this will be an image that shows a great deal of gray levels details and has
high dynamic range.
www.rocktheit.com www.facebook.com/rocktheit
25 Image Enhancement in the Spatial Domain
dr
Ps s Pr r ,
ds
Thus the PDF of the transformed variable s is the determined by the gray levels PDF of the
input image and by the chosen transformations function.
A transformation function of a particular importance in image processing
s T r Pr w dw.
r
Thus a processed image is obtained by mapping each pixel with levels rk in the input image
into acorresponding pixel with level sk in the output image.
A plot of Pr (rk) versus rk is called a histogram.
www.rocktheit.com www.facebook.com/rocktheit
26 Image Enhancement in the Spatial Domain
The transformation function given by the above equation is the called histogram
equalization or linearization.
Given an image the process of histogram equalization consists simple of implementing the
transformation function which is based information that can be extracted directly from the
given image, without the need for further parameter specification.
www.rocktheit.com www.facebook.com/rocktheit
27 Image Enhancement in the Spatial Domain
In earlier methods pixels were modified by a transformation function based on the gray
level of an entire image.
It is not suitable when enhancement is to be done in some small areas of the image.
This problem can be solved by local enhancement where a transformation function is
applied only in the neighborhood of pixels in the interested region.
Define square or rectangular neighborhood (mask) and move the center from pixel to pixel.
For each neighborhood
1. Calculate histogram of the points in the neighborhood
2. Obtain histogram equalization/specification function
3. Map gray level of pixel centered in neighborhood
4. The center of the neighborhood region is then moved to an adjacent pixel location and
the procedure is repeated.
These operations are performed on a pixel by basis between two or more images excluding
not operation which is performed on a single image.
It depends on the hardware and/or software that the actual mechanism of implementation
should be sequential, parallel or simultaneous.
Logic operations are also generally operated on a pixel by pixel basis.
Only AND, OR and NOT logical operators are functionally complete.
Because all other operators can be implemented by using these operators.
www.rocktheit.com www.facebook.com/rocktheit
28 Image Enhancement in the Spatial Domain
While applying the operations on gray scale images, pixel values are processed as strings
of binary numbers.
The NOT logic operation performs the same function as the negative transformation.
Image Masking is also referred to as region of Interest (RoI) processing.
This is done to highlight a particular area and to differentiate it from the rest of the image.
Out of the four arithmetic operations, subtraction and addition are the most useful for image
enhancement.
www.rocktheit.com www.facebook.com/rocktheit
29 Image Enhancement in the Spatial Domain
medium isinjected into the patient’s blood storm and then a series of image are taken of the
region same as
h(x,y).
The mask is then subtracted from the series of incoming image.
This subtraction will give the area which will be the difference between f(x,y) and h(x,y) this
difference will be given as enhanced detail in the output image.
Consider a noisy image g(x,y) formed by the addition of noise n(x,y) to the original image
f(x,y)
g(x,y) = f(x,y) + n(x,y)
Assuming that at every point of coordinate (x,y) the noise is uncorrelated and has zero
average value
The objective of image averaging is to reduce the noise content by adding a set of noise
images,
{gi(x,y)}
If in image formed by image averaging K different noisy images
1 K
g x, y gi x, y
K i 1
E g x, y f x, y
As k increases the variability (noise) of the pixel value at each location (x,y) decreases.
E{g(x,y)} = f(x,y) means that g(x,y) approaches f(x,y) as the number of noisy image used in
the averaging processes increases.
Image averaging is important in various applications such as in the field of astronomy
where the images are low light levels.
3.10 SUMMARY
www.rocktheit.com www.facebook.com/rocktheit
30 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit
31 Image Enhancement in the Spatial Domain
Gray level r 0 1 2 3 4 5 6
No. of pixels with 200 170 130 60 60 80 140
gray level nr
10) Obtain the Threshold image for the 3 Bit image below.
Choose appropriate threshold value T.
www.rocktheit.com www.facebook.com/rocktheit
32 Image Enhancement in the Spatial Domain
1 2 2 2 2
3 3 5 6 2
7 4 4 7 0
7 6 6 5 0
0 7 3 7 1
3 2 1 4
7 0 7 0
5 4 6 2
4 4 3 1
4 3 0 2
0 7 6 5
www.rocktheit.com www.facebook.com/rocktheit
33 Image Enhancement in the Spatial Domain
www.rocktheit.com www.facebook.com/rocktheit