0% found this document useful (0 votes)
29 views59 pages

Mpa 3

PPT of Digital Enhancement Topic in Digital Image Processing

Uploaded by

Shubham Mittal
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)
29 views59 pages

Mpa 3

PPT of Digital Enhancement Topic in Digital Image Processing

Uploaded by

Shubham Mittal
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
You are on page 1/ 59

Digital Image Processing

Image Enhancement-
What Is Image Enhancement?
Image enhancement is the process that
improves the quality of the image for a
specific application
The reasons for doing this include:
◦ Highlighting interesting detail in images
◦ Removing noise from images
◦ Making images more visually appealing
Spatial & Frequency Domains
There are two broad categories of image
enhancement techniques
◦ Spatial domain techniques
 Direct manipulation of image pixels
◦ Frequency domain techniques
 Manipulation of Fourier transform or wavelet
transform of an image
Spatial Domain Enhancement
 The term spatial domain refers to the aggregate of
pixels composing an image. Spatial domain methods
are procedures that operate directly on these pixels.

 Mathematically spatial domain enhancement has been


defined as:

g(x, y) =T[f(x, y)]

g(x, y)= processed image,


f(x, y) = input image
T= an operator
Gray Level Transformation
 Point processing:- Point processing methods
are based only on the intensity of single pixels.
 Contrast Stretching:- produce an image of
higher contrast than the original image.
 Mask processing or filtering:- use a function in
a predefined neighborhood of pixel to
determine the value at enhanced mode.
The Linear Transformation
255
It is of the form: f(r) = m . r + c

Where m = slope = y/x f(r) y


c = Y - intercept
x
c

0 r 255
The user may input both values of ‘m’ and ‘c’
Brightness
255
Consider the picture of Einstein here.

In order to make the Image darker we


make ‘c’ < 0. f(r)
bright

In order to make the Image brighter we


make ‘c’ > 0. dark

0 r 255

c = -80 c = 80
0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250

0.18

0.16

0.14

0.12

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250
Contrast
255
Consider again the picture of Einstein.

In order to increase the contrast all we


have to do is increase the slope ‘m’. f(r)
low

Similarly, in order to decrease the high


contrast we decrease the slope.

0 r 255

m = 3.0 m = 0.3
0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250

0.2

0.15

0.1

0.05

0
0 50 100 150 200 250

0.07

0.06

0.05

0.04

0.03

0.02

0.01

0
0 50 100 150 200 250
Basic Point Processing
Identity Functions
◦ Output intensities are identical to input
intensities
◦ This function doesn’t have an effect on an
image, it was included in the graph only for
completeness
◦ Its expression:
s=r
Negative Functions
◦ The negative of an image
with gray level in the range
[0, L-1], where L = Largest
value in an image, is
obtained by using the
negative transformation’s
expression:

s=L–1–r

Which reverses the


intensity levels of an input
image, in this manner
produces the equivalent of
a photographic negative.
Example of Image Negatives
Negative Functions
• The negative transformation is
suitable for enhancing white
or gray detail embedded in
dark regions of an image,
especially when the black area
are dominant in size
Log Transformation

s = c log(1+r)
c: constant, r≥0

 Maps a narrow range of low gray-level values in


the input image into a wider range of output
levels and opposite is also true for higher values
of input levels.

 It is used to expand the values of dark pixels in


an image while compressing the higher order
values.

 The value of c in the log transform adjust the


kind of enhancement you are looking for.
Log Transformation
For example: Fourier spectra are mostly scaled using the Log Transformation before
display.

Log
Inverse Logarithmic Transformations
◦ Do opposite to the
log transformations
◦ Used to expand the
values of high pixels
in an image while
compressing the
darker-level values.
Power-Law Transformation

s  cr
c,  : positive constants

•Power-law curves with fractional values


of  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 levels

• A family of possible transformation


curves obtained simply by varying .
•The graph shows the power law
transformation for C =1.
•Curves generated with values of >1
have exactly the opposite effect with
values of <1.
•If c= =1, then it transforms into identity
transformation.
This is an Ariel image that has a washed-out appearance.

Here a compression of gray-levels is desirable.


The effect of processing the image with a γ = 3 yields this result.
Piecewise-Linear Transformation
 Principle Advantage: Some important
transformations can be formulated only as a
piecewise function.
 Types of Piecewise transformations are:
◦ Contrast Stretching
◦ Gray-level Slicing
◦ Bit-plane slicing
Contrast Stretching
 Contrast = difference in intensity between the highest and
the lowest intensity levels in an image

 Contrast Stretching: is a simple image enhancement


technique that improves the contrast in an image by
‘stretching’ the range of intensity values it contains to
span a desired range of values.
 One of the simplest piecewise linear functions is a
contrast-stretching transformation, which is used to
enhance the low contrast images.
 Low contrast images may result from:
◦ Poor illumination
◦ Wrong setting of lens aperture during image acquisition.
Piecewise-Linear Transformation
Contrast Stretching is used 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.

It is generally assumed that r1 ≤ r2 and s1 ≤ s2.

Let us consider some examples.


r 1 = s1 r 2 = s2

Transformation is a linear function and produces no changes.


r1 = r2 s1 = 0 s2 = L-1

Transformation is a thresholding function creating a binary image.

r1 = r2= 102
0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.5

0.45

0.4

0.35

0.3

0.25

0.2

0.15

0.1

0.05

0
0 50 100 150 200 250
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.

r1 = 71 r2= 115 s1 = 17 s2 = 226


0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250
Summary of Contrast Stretching
 The locations of points (r1, s1) and (r2, s2)
control the shape of the transformation
function.
 If r1 = s1 and r2 = s2, the transformation is
a linear function that produces no changes
in gray levels.
 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.
 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 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].
 In general, r1 ≤ r2 and s1 ≤ s2 is assumed,
so the function is always increasing.
Problem on Contrast Stretching

Consider an 8 X 8 image, where each pixel is represented by 3 bit

Gray 0 1 2 3 4 5 6 7
levels
No of 0 0 5 20 20 19 0 0
occure
nces

Perform contrast stretching in full length and calculate the output


Gray level with their number of occurrences.
Gray-level Slicing
 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 a
low value for all other gray
levels. This transformation
produces a binary image.
◦ The second approach,
brightens the desired range
of gray levels but preserves
gray levels unchanged.
Bit-plane Slicing
 Pixels are digital numbers, each one composed of bits. Instead of
highlighting gray-level range, we could highlight the contribution
made by each bit.
 This method is useful and used in image compression.

 Most significant bits contain the majority of visually significant data.


 The least significant bit planes contribute to more subtle details in
the image
Here is a fractal image.

Let us the it’s constituent bit-planes.

The MSB contains the most information while


the LSB contains the least amount of information.
Let us take the look at the effect of removing the last 4 bits .

Now compare this with the original image.


What is a Histogram?
 In Statistics, Histogram is a graphical
representation showing a visual
impression of the distribution of data.
 An Image Histogram is a type of
histogram that acts as a graphical
representation of the lightness/color
distribution in a digital image. It plots the
number of pixels for each value.
Histogram
 Histogram of an image represents the
relative frequency of occurrence of various
gray levels in the image
 The histogram of a digital image with gray
levels from 0 to L-1 is a discrete function
h(rk)=nk, where:
◦ rk is the kth gray level
◦ nk is the number of pixels in the image with that
gray level
◦ n is the total number of pixels in the image
◦ k = 0, 1, 2, …, L-1
Histogram Processing
 It is common practice to normalize a histogram
by dividing each of its values by the total number
of pixels in the image, denoted by n.
 Thus, a normalized histogram is given by

p(rk) = nk / n, for k = 0, 1, …, L -1.

 Thus, p(rk) gives an estimate of the probability of


occurrence of gray level rk. Note that the sum of
all components of a normalized histogram is
equal to 1.
The shape of the histogram provides useful information

In the case of a dark image, the components of the histogram are concentrated on
the low side of the gray scale.

Similarly the components of the histogram of a bright image are concentrated on the
high side of the gray scale.

0.18

0.16

0.14

0.12

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250
In the case of a low contrast image the histogram is narrow and centered towards the
middle of the gray scale.

It is spread out in the case of a high contrast image.

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250
How to calculate Histogram in programming
// f(0…M-1, 0…N-1)=image // f(0…M-1, 0…N-1)=image
// h(0…255)=histogram =0; // h(0…255)=histogram =0;
for k=0 to 255
{ for i=0 to M-1
for i=0 to M-1 {
{ for j=0 to N-1
for j=0 to N-1 {
{ a=f(i,j);
if f[i,j]==k h[a]+=1;
{ }
h[k]+=1; }
}
}
}
} // Loop=MXN
//Loop=MXNX256
Why Histogram?
 Histograms are the basis for numerous
spatial domain processing techniques
 Histogram manipulation can be used
effectively for image enhancement
 Histograms can be used to provide useful
image statistics
 Information derived from histograms are
quite useful in other image processing
applications, such as image compression
and segmentation.
Why Histogram?
4
x 10
4

3.5

2.5

1.5

0.5

0 50 100 150 200 250

It is a baby in the cradle!

Histogram information reveals that image is under-exposed

44
Another Example
7000

6000

5000

4000

3000

2000

1000

0 50 100 150 200 250

Over-exposed image
 An image whose pixels tend to occupy
the entire range of possible gray levels, in
addition, tend to be distributed uniformly,
will have an appearance of high contrast
and will exhibit a large variety of gray
tones.
Histogram Equalization
What is the histogram equalization?
The histogram equalization is an approach to enhance a given
image. The approach is to design a transformation T(.) such that
the gray values in the output is approximately uniformly
distributed in [0, 1].
Let us assume for the moment that the input image to be
enhanced has gray values, with r = 0 representing
black and r = 1 representing white.

We need to design a gray value transformation s = T(r), based


on the histogram of the input image, which will enhance the
image.
◦ Basic idea: find a map T(r) such that the
histogram of the modified (equalized) image is
flat .
◦ Key motivation: cumulative distribution
function (cdf) of a random variable
approximates a uniform distribution
CDF
 The CDF is monotonically increasing
 The derivative (slope) of the CDF is steep
where there is a lot of information in the
source and is flat where there is little
information in the source.
 The CDF of a perfectly equalized image is
a straight line with a slope of 1.

49
Histogram Equalization

s  T (r ) 0  r  L 1
a. T(r) is a strictly monotonically increasing function
in the interval 0  r  L -1;
b. 0  T (r )  L -1 for 0  r  L -1.

8/21/2024 50
How to implement histogram equalization?

Step 1:For images with discrete gray values, compute:

nk
pr (rk )  0  rk  1 0  k  L 1
n
L: Total number of gray levels
nk: Number of pixels with gray value rk

n: Total number of pixels in the image

Step 2: Based on CDF, compute the discrete version of the previous


transformation :

k
sk  T (rk )   pr (rj ) 0  k  L 1
j 0
Effect of applying the Histogram Equalization.

0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250

0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004

0.002

0
0 50 100 150 200 250
Another example highlighting the effectiveness of this technique

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250

0.1

0.08

0.06

0.04

0.02

0
0 50 100 150 200 250
Histogram Equalization

Continuous case:
r
s  T (r )  ( L  1)  pr ( w)dw
0

Discrete values:
k
sk  T (rk )  ( L  1) pr (rj )
j 0
k nj L 1 k
 ( L  1)   nj k=0,1,..., L-1
j  0 MN MN j 0

8/21/2024 54
Example: Histogram Equalization

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 p s(sk) for each
s k.

8/21/2024 55
Example: Histogram Equalization

0
s0  T (r0 )  7 pr (rj )  7  0.19  1.33 1
j 0
1
s1  T (r1 )  7 pr (rj )  7  (0.19  0.25)  3.08 3
j 0
s2  4.55  5 s3  5.67  6
s4  6.23  6 s5  6.65  7
s6  6.86  7 s7  7.00  7
8/21/2024 56
Example: Histogram Equalization

8/21/2024 57
Histogram Equalization
Here, the goal is to obtain a uniform histogram for the output image.
Some features of Histogram equalization are as follows:

• Histogram equalization is a point process

• Histogram equalization causes a histogram with closely grouped values to


spread out into a flat or equalized histogram.

• Spreading or flattening the histogram makes the dark pixels appear darker
and the light pixels appear lighter.

• Histogram equalization does not operate on the histogram itself but uses
the results of one histogram to transform the original image into an image
that will have equalized histogram.

• Histogram equalization do not introduce new intensities in the image.


Existing values will be mapped to new values keeping actual number of
intensities in the resulting image equal or less than the original number of
intensities.
Thank You

You might also like