0% found this document useful (0 votes)
12 views53 pages

Image Enhancement Techniques Overview

Chapter 3 discusses image enhancement techniques in the spatial domain, focusing on improving image quality and information content through various methods such as intensity transformation, histogram processing, and spatial filtering. It outlines the principles of image enhancement, the importance of contrast, and the subjective nature of image quality evaluation. The chapter also covers specific techniques like contrast stretching, histogram equalization, and gray-level slicing, providing insights into their applications and effects on image processing.

Uploaded by

Tuhar Ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views53 pages

Image Enhancement Techniques Overview

Chapter 3 discusses image enhancement techniques in the spatial domain, focusing on improving image quality and information content through various methods such as intensity transformation, histogram processing, and spatial filtering. It outlines the principles of image enhancement, the importance of contrast, and the subjective nature of image quality evaluation. The chapter also covers specific techniques like contrast stretching, histogram equalization, and gray-level slicing, providing insights into their applications and effects on image processing.

Uploaded by

Tuhar Ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 3

Image Enhancement in spatial domain


PREPARED BY: ATLAW M

1/17/2024 1
Content
• Spatial Processing of Digital Images
• Basic Intensity Transformation Functions
• Histogram of images
• Spatial filtering
• Histogram processing
• Combining Spatial Enhancement Methods

1/17/2024 2
Principle Objective of Enhancement
•Image enhancement is the procedure of improving the quality and the information
content of original data before processing.

•To Process an image so that the result will be more suitable than the original image
for a specific application.

• The techniques are problem oriented.

• A method which is quite useful for enhancing an image may not necessarily be the
best approach for enhancing another image.

1/17/2024 3
Why enhancement?
Images may suffer from the following degradations:
➢Poor contrast due to poor illumination or finite sensitivity of the
imaging device.

➢Electronic sensor noise or atmospheric disturbances leading to


broadband noise.

➢Aliasing effects due to inadequate sampling.

➢Finite aperture effects or motion leading to spatial degradation of the


image.

1/17/2024 4
Good images
For human visual

◦ The visual evaluation of image quality is a highly subjective process.

◦ It is hard to standardize the definition of a good image.

For machine perception


◦ The evaluation task is easier.

◦ A good image is one which gives the best machine recognition results.

A certain amount of trial and error usually is required before a particular


image enhancement approach is selected.

1/17/2024 5
Spatial domain methods
•Spatial domain refers to the aggregate of pixels composing an image or the
image plane itself.
•Approaches in this categories are based on direct manipulation of pixel in an
image.
•Spatial domain process are denoted by the expression
◦ g(x,y)=T[f(x,y)]
◦ f(x,y)- input image
◦ T- operator on f, defined over some neighborhood of f(x,y)
◦ g(x,y)-processed image
•Neighborhood can be any shape but generally it is rectangular ( 3x3, 5x5, 9x9
etc).

1/17/2024 6
Cont…
•The neighborhood of a point (x,y) can be explained by using a square or
rectangular sub image area centered at (x,y).

•The center of sub image is moved from pixel

to pixel starting at the top left corner.

•The operator T is applied to each location

(x,y) to find the output g at that location .

•The process utilizes only the pixel in the area

of the image spanned by the neighborhood.


A 3*3 neighborhood about a point (x, y) in an image.
1/17/2024 7
Basic Gray Level Transformation Functions
•The smallest possible neighborhood is of size 1 x 1.

•In this case, g depends only on the value of f at a single point (x, y) and T
becomes an intensity (also called a gray-level, or mapping) transformation
function of the form:
◦ S=T(r)

◦ Where, r- Denotes the gray level of f(x,y)

◦ s- Denotes the gray level of g(x,y) at any point (x,y)

▪ There are three kinds of functions in gray level transformation:


◦ Point Processing

◦ Basic Gray Level Transformation

◦ Piece wise linear transformation functions

1/17/2024 8
Point processing
1. Contract stretching:
• It produces an image of higher contrast than the original one.

• The operation is performed by darkening the levels below k and brightening


the levels above k in the original image.

• In this technique the value of r below k are compressed by the transformation


function into a narrow range of s towards black.

• The opposite effect takes place for the values of r above k.

1/17/2024 9
Cont…
2. Thresholding function:
▪ It is a limiting case where T(r) produces a two levels binary image.

▪ The values below k are transformed as black and above k are transformed as
white.

1/17/2024 10
Basic Gray Level Transformation
These are the simplest image enhancement techniques.

1. Image Negative:
▪ The negative of an image with gray level in the range of [0, L-1] is obtained
by using the negative transformation.

▪ The expression of the transformation is s= L-1-r

▪ Reverting the intensity levels of an image in this manner produces the


equivalent of a photographic negative.

1/17/2024 11
Cont…
2. Log transformations:
• The general form of the log transformation is s= c log(1+r)
• Where c- constant and r ≥ 0

• This transformation maps a narrow range of gray level values in the input
image into a wider range of output gray levels. The opposite is true for higher
values of input levels.

• We would use this transformations to expand the values of dark pixels in an


image while compressing the higher level values. The opposite is true for
inverse log transformation.

1/17/2024 12
Cont…
3. Power Law Transformation:
• Power law transformations has the basic form
• Where c and y are positive constants.

• Power law curves with fractional values of y map a narrow range of dark
input values into a wider range of output values, with the opposite being true
for higher values of input gray levels.

• We may get various curves by varying values of y.

1/17/2024 13
Cont…
The three have generalized by the following graphs:

1/17/2024 14
Piece wise linear transformation functions

▪ The principal advantage of piecewise linear functions is that these functions


can be arbitrarily Complex.

▪ But their specification requires considerably more user input.

1. Contrast Stretching:
• We may have various low contrast images and that might result due to various
reasons such as lack of illumination, problem in imaging sensor or wrong
setting of lens aperture during image acquisition.

• The idea behind contrast stretching is to increase the dynamic range of gray
levels in the image being processed.

1/17/2024 15
Cont….
The location of points (r1,s1) and (r2,s2) control the shape of the curve
A. If r1=r2 and s1=s2, the transformation is a linear function that deduces no
change in gray levels.

B. If r1=s1, s1=0 , and s2=L-1, then the transformation become a thresholding


function that creates a binary image.

C. Intermediate values of (r1, s1) and (r2, s2) produce various degrees of spread
in the gray value of the output image thus effecting its contract, so that the
function is single valued and monotonically increasing.

1/17/2024 16
Cont…
• Fig. 3.10(a) shows a typical transformation used for
contrast stretching.

• Fig. 3.10(b) a low-contrast image : result from poor


illumination, lack of dynamic range in the imaging
sensor, or even wrong setting of a lens aperture of
image acquisition.

• Fig. 3.10(c) shows the result of contrast stretching,


obtained by setting (r1, s1) ( rmin, 0) and (r2, s2)
(rmax, L-1) where rmin and rmax denote the minimum
and maximum intensity levels in the input image.

• Fig. 3.10(d) shows the result of using the thresholding


function, with (r1,s1) (m,0) and (r2, s2) (m, l-1)where
m is the mean intensity level in the image.

1/17/2024 17
Cont…
2. Gray Level Slicing
• Highlighting a specific range of gray levels in an image is often desirable.

• E.g. when enhancing features such as masses of water in satellite image and
enhancing flaws in x- ray images.

There are two ways of doing this:


• One method is to display a high value for all gray level in the range of interest
and a low value for all other gray level.

• Second method is to brighten the desired ranges of gray levels but preserve
the background and gray level tonalities in the image.

1/17/2024 18
Cont…
E.g.

1/17/2024 19
Cont…
3. Bit Plane Slicing
• Sometimes it is important to highlight the contribution made to the total
image appearance by specific bits. Suppose that each pixel is represented
by 8 bits.

• Imagine that an image is composed of eight 1-bit planes ranging from bit
plane 0 for the least significant bit to bit plane 7 for the most significant bit.
In terms of 8-bit bytes, plane 0 contains all the lowest order bits in the
image and plane 7 contains all the high order bits.

1/17/2024 20
Cont…
For instance:

1/17/2024 21
Histogram Processing
• Histogram of a digital image with gray levels in the range [0,L-1] is a
discrete function:

• Similarly, the normalized histogram of f is defined as:

1/17/2024 22
Cont…
• The histogram manipulation is a fundamental tool in image processing.

• Histograms are simple to compute and are also suitable for fast hardware
implementations, thus making histogram-based techniques a popular tool for
real-time image processing.

• Histogram shape is related to image appearance. For example, Fig. 3.16


shows images with four basic intensity characteristics: dark, light, low
contrast, and high contrast; the image histograms are also shown.

1/17/2024 23
Cont…
▪Dark image
◦ Components of histogram are concentrated on the low side of the gray scale.

▪Bright image
◦ Components of histogram are concentrated on the high side of the gray scale.

▪Low-contrast image
◦ The histogram is narrow and centered toward the middle of the gray scale

▪High-contrast image
◦ The histogram covers broad range of the gray scale and the distribution of pixels
is not too far from uniform, with very few vertical lines being much higher than
the others.

1/17/2024 24
Histogram Equalization
◦ Histogram equalization is a common technique for enhancing the appearance
of images.

◦ Suppose we have an image which is predominantly dark. Then its histogram


would be skewed towards the lower end of the grey scale and all the image
detail are compressed into the dark end of the histogram.

◦ We assume that r is in the range [0, L−1] with r = 0 representing black and r =
L−1 representing white. For r satisfying these conditions, transformations
(intensity mappings) of the form:

◦ We assume that:
a) T(r) is a monotonic increasing function in the interval 0≤ r ≤ L−1; and

b) 0 ≤ T(r) ≤ L −1 for 0 ≤ r≤ L −1 .

1/17/2024 25
Cont…
We use the inverse transformation:

In which case we change condition (a) to:


◦ T(r) is a strictly monotonic increasing function in the interval 0 ≤ r ≤ L-1

1/17/2024 26
Cont…
Implementation:

1. Obtain the histogram of the input image.

2. For each input gray level k, compute the cumulative sum.

3. For each gray level k, scale the sum by(max gray level)/(number of
pixels).

4. Discretize the result obtained in 3.

5. Replace each gray level k in the input image by the corresponding


level obtained in 4.

1/17/2024 27
Cont…
• A fundamental result from probability theory is that if pr(r) and T(r) are
known, and T(r) is continuous and differentiable over the range of values of
interest, then the PDF of the transformed (mapped) variable s can be obtained
as

• A transformation function of particular importance in image processing is

❖ Where w is a dummy variable of integration. The integral on the right side is the cumulative
distribution function (CDF) of random variable r.

• We know from Leibniz’s rule in calculus that the derivative of a definite integral with
respect to its upper limit is the integrand evaluated at the limit.

1/17/2024 28
Cont….
• Substituting this result for dr/ds in the above equation and noting that all
probability values are positive, gives the result:

• We recognize the form of ps(s) in the last line of this equation as a uniform
probability density function. Thus, performing the intensity transformation in
the above equation yields a random variable, s, characterized by a uniform
PDF.

1/17/2024 29
Cont…
• Recall that the probability of occurrence of intensity level rk in a digital
image is approximated by:

• The discrete form of the transformation

• Where, as before, L is the number of possible intensity levels in the image


(e.g., 256 for an 8-bit image). Thus, a processed (output) image is obtained by
using above equation to map each pixel in the input image with intensity rk
into a corresponding pixel with level sk in the output image, This is called a
histogram equalization or histogram linearization transformation.

1/17/2024 30
Cont…
◦ Suppose that a 3-bit image (L = 8) of size 64× 64 pixels (MN = 4096) has the
intensity distribution in below Table, where the intensity levels are integers in
the range [0, L-1] [0,7].

◦ The transformation yielded only five distinct intensity levels.


◦ Because r0 = 0 was mapped to s0 = 1, there are 790 pixels
◦ 1023 pixels with a value of s1 = 3 and 850 pixels with a value of s2 = 5. both
r3 and r4 were mapped to the same value 6 so there are (656 + 329 = 985)
pixels (245 +122+81= 448 ) pixels with a value of 7 in the histogram
equalized image.

1/17/2024 31
Cont…

The final results from the above examples

1/17/2024 32
Cont…
◦ Exercise, Suppose that a 3-bit image as shown in the following tables
performing the histogram equalization:

1/17/2024 33
Cont…
•A gray-level transformation method that forces the transformed gray
level to spread over the entire intensity range.
▪ Fully automatic,

▪ Data dependent,

▪ Contrast enhanced.

•Usually, the discrete-valued histogram equalization algorithm does not


yield exact uniform distribution of histogram.

1/17/2024 34
Histogram Matching (Specification)

• Histogram equalization has a disadvantage which is that it can


generate only one type of output image.

• With Histogram Specification, we can specify the shape of the


histogram that we wish the output image to have.

• It doesn’t have to be a uniform histogram.

1/17/2024 35
Cont…
◦ Consider for a moment continuous intensities r and z which, as before, we
treat as random variables with PDFs pr(r) and pz(z), respectively. Here, r and
z denote the intensity levels of the input and output (processed) images,
respectively.

◦ We can estimate pr(r) from the given input image, and pz(z) is the specified
PDF that we wish the output image to have.

◦ Let s be a random variable with the property:

◦ Define a function G on variable z with the property:

1/17/2024 36
Cont…
◦ It follows from the preceding two equations that G(z)= s T( r) and, therefore,
that z must satisfy the condition:

◦ The procedure that have been follows:

1. Obtain the transformation function T(r) by calculating the histogram


equalization of the input image:

2. Obtain the transformation function G(z) by calculating histogram


equalization of the desired density function:

1/17/2024 37
Cont…
3. Obtain the inversed transformation function G-1

• For every value of sk K= 0, 1, 2,….. L-1 use the stored values of G from
Step 2 to find the corresponding value of zq so that G (zq) is closest to sk,
Store these mappings from s to z.

• When more than one value of zq gives the same match (i.e., the mapping is
not unique), choose the smallest value by convention.

4. Obtain the output image by applying the processed gray-level from the
inversed transformation function to all the pixels in the input image.

1/17/2024 38
Cont…
E.g. Consider the 64x64 hypothetical image from the above example:
◦ The first step is to obtain the histogram-equalized values:

◦ In the next step, we compute the values of G (zq) using the values of pz(zq) from
the above table using the specified histogram values:

1/17/2024 39
Cont…

•These fractional values are rounded to integers in the range [0,7]:

•In step three, we find the smallest value of zq so that the value G(zq) is
the closest to sk . We do this for every value of sk to create the required
mappings from s to z.
•For example, s0 = 1, and we see that G(z3) = 1 which is a perfect match
in this case, so we have the correspondence s0 → z3. Every pixel whose
value is 1 in the histogram equalized image would map to a pixel valued
3 in the histogram-specified image.

1/17/2024 40
Cont…
◦ The above values shows:

◦ The values of pz(zq) were obtained using the same procedure as in, For
instance, sk = 1 maps to zq = 3, and there are 790 pixels in the histogram
equalized image with a value of 1. Therefore, pz(z3 ) = 790/4096 ➔ 0.19,
they continue for others

1/17/2024 41
Cont…

A. Histogram of a 3-bit image.

B. Specified histogram.

C. Transformation function obtained


from the specified histogram.

D. Result of histogram specification.


Compare the histograms in (b)
and (d).

1/17/2024 42
Fundamentals of spatial filter
◦ Filtering refers to passing, modifying, or rejecting specified
frequency components of an image.

◦ Spatial filtering modifies an image by replacing the value of each


pixel by a function of the values of the pixel and its neighbors.

◦ If the operation performed on the image pixels is linear, then the filter
is called a linear spatial filter. Otherwise, the filter is a nonlinear
spatial filter.

1/17/2024 43
Linear spatial filtering
◦ A linear spatial filter performs a sum-of-products operation between an image
f and a filter kernel, w.

◦ The kernel is an array whose size defines the neighborhood of operation, and
whose coefficients determine the nature of the filter, our focus will be on
masks of odd sizes, e.g. 3x3, 5x5,…

◦ At any point (x, y) in the image, the response, g(x,y), of the filter is the sum
of products of the kernel coefficients and the image pixels encompassed by
the kernel:

1/17/2024 44
Cont…
◦ In general, linear spatial filtering of an image of size MxN with a kernel of
size mxn is given by the expression:

◦ where a = (m-1)/2 and b = (n-1)/2, To generate a complete filtered image this


equation must be applied for x = 0, 1, 2, … , M-1 and y = 0, 1, 2, … , N-1.

1/17/2024 45
Spatial correlation and convolution
◦ Correlation consists of moving the center of a kernel over an image, and
computing the sum of products at each location.

◦ The mechanics of spatial convolution are the same, except that the correlation
kernel is rotated by 180°.

◦ Thus, when the values of a kernel are symmetric about its center, correlation
and convolution yield the same result.

◦ We begin with a 1-D illustration, in which case following Eq. becomes:

1/17/2024 46
Cont…
◦ The mechanics of linear spatial filtering using a 3x3 kernel. Note that the
origin of the image is at the top left, but the origin of the kernel is at its center.

Spatial filter mask

Image section under filter

1/17/2024 47
Cont…
◦ Examples shows a 1-D function f, and a kernel, w. The kernel is of size 1x5:

1/17/2024 48
Cont…
As continue the above example:

1/17/2024 49
Cont…
◦ The following examples show as performing correction and convolution in
2D:

1/17/2024 50
Cont…
◦ As performing convolution as rotate the W with 180.

1/17/2024 51
Cont…
◦ The correlation of a kernel w of size m x n with an image f (x, y),
denoted as (w * f (x, y ), which we repeat here for convenience:

◦ In a similar manner, the convolution of a kernel w of size m x n with


an image f (x, y), denoted by (w * f(x, y )), is defined as:

1/17/2024 52
Cont…
Reading assignment
◦ Smoothing spatial filters

◦ Spatial Averaging or Lowpass Filter

◦ Mean Filters

◦ Median Filters

1/17/2024 53

You might also like