0% found this document useful (0 votes)
36 views65 pages

DIP Lec 6 - 7 - 8 - 9

Uploaded by

Divishtha Malik
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)
36 views65 pages

DIP Lec 6 - 7 - 8 - 9

Uploaded by

Divishtha Malik
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/ 65

EEE F435 (2021-22-I)

Digital Image Processing


(Image Enhancement in the Spatial
BITS Pilani Domain : Point Processing)
K K Birla Goa Campus
Ashish Chittora
Principle Objective of
Enhancement
• Process an image so that the result will be more
suitable than the original image for a specific
application.

• Suitability of method depends on application.

• A method which is quite useful for enhancing an


image may not necessarily be the best approach
for enhancing some other images
Types
• Spatial Domain : (image plane)
– Intensity transformation: Techniques are based on
direct manipulation of pixels in an image
– Spatial filtering: Neighboring pixels also affect the
operation on a pixel
• Frequency Domain :
– Techniques are based on modifying the Fourier-
transform coefficients of an image
• There are some enhancement techniques based
on various combinations of methods from these
two categories.
Criteria
• For human visual perception
– The visual evaluation of image quality is a highly
subjective process.
– It is hard to standardize the definition of a good or
better 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.
Spatial Domain
• Procedures that operate
directly on pixels.
g(x,y) = T[f(x,y)]
where
– f(x,y) is the input image
– g(x,y) is the processed
image
– T is an operator on f
defined over some
neighborhood of (x,y)
• Types
– Point processing
– Mask processing
Point Processing
• Neighborhood = 1x1 pixel
• g depends on only the value of f at (x,y)
• T = gray level (or intensity or mapping)
transformation function
s = T(r)
• Where
• r = gray level of f(x,y)
• s = gray level of g(x,y)
3 basic gray-level
transformation functions
• Linear function
Negative
– Negative and identity
nth root
transformations
• Logarithm function
Log
nth power – Log and inverse-log
transformation
• Power-law function
– nth power and nth root
Identity Inverse Log
transformations

Input gray level, r


Identity function
• Output intensities are
identical to input
intensities.
• Is included in the
graph only for
completeness.
• s=T(r)
=> s=r
Image Negatives
• An image with gray level in the range [0, L-1]
where L = 2n ; n = 1, 2…
• Negative transformation :
s = (L – 1) –r
• Reversing the intensity levels of an image.
• Suitable for enhancing white or gray detail
embedded in dark regions of an image, especially
when the black area dominant in size.
Example of Negative Image
Division operation
Multiplication operation
Log Transformations
s = c log (1+r)
• c is a constant
Negative and r  0
nth root
• Log curve maps a narrow
range of low gray-level
Log
nth power values in the input image
into a wider range of
output levels.
• Used to expand the
values of dark pixels in an
Identity Inverse Log
image while compressing
the higher-level values.
Input gray level, r
Example of Logarithm Image

Fourier Spectrum with Result after apply the log


range = 0 to 1.5 x 106 transformation with c = 1,
range = 0 to 6.2
Inverse Logarithm
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 Transformations
s = cr
• c and  are 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.
• c =  = 1  Identity
Input gray level, r
function
Plots of s = cr for various values of 
(c = 1 in all cases)
Power Law transformations
Another example : MRI a b
c d

(a) a magnetic resonance image of


an upper thoracic human spine
with a fracture dislocation and
spinal cord impingement
– The picture is predominately dark
– An expansion of gray levels are
desirable  needs  < 1
(b) result after power-law
transformation with  = 0.6, c=1
(c) transformation with  = 0.4
(best result)
(d) transformation with  = 0.3
(under acceptable level)
Effect of decreasing gamma
• When the  is reduced too much, the
image begins to reduce contrast to the
point where the image started to have very
slight “wash-out” look, especially in the
background
a b
c d
Another example
(a) image has a washed-out
appearance, it needs a
compression of gray levels
 needs  > 1
(b) result after power-law
transformation with  = 3.0
(suitable)
(c) transformation with  = 4.0
(suitable)
(d) transformation with  = 5.0
(high contrast, the image has
areas that are too dark,
some detail is lost)
Piecewise-Linear
Transformation Functions
• Advantage:
– The form of piecewise functions can be
arbitrarily complex
• Disadvantage:
– Their specification requires considerably
more user input
Piecewise-Linear
Transformation Functions
•Contrast stretching
•Intensity level slicing
•Bit-plane slicing
Contrast Stretching
• increase the dynamic range of the
gray levels in the image
• a low-contrast image : result from
poor illumination, lack of dynamic
range in the imaging sensor, or
wrong setting of a lens aperture of
image acquisition
• It’s a process to expand the range
of intensity levels in image so that
is spans the full intensity range of
the recording medium or display
device
Thresholding
• Produce a two-level (binary) image
– darkening the levels below m in the original image
– Brightening the levels above m in the original image
Gray-level slicing
• Highlighting a specific
range of gray levels in an
image
– Display a high value of all
gray levels in the range of
interest and a low value for
all other gray levels
• (a) transformation highlights
range [A,B] of gray level and
reduces all others to a constant
level
• (b) transformation highlights
range [A,B] but preserves all
other levels
Bit-plane slicing
• Highlighting the contribution
One 8-bit byte Bit-plane 7
(most significant) made to total image
appearance by specific bits
• Suppose each pixel is
represented by 8 bits
• Higher-order bits contain the
majority of the visually
significant data
Bit-plane 0 • Useful for analyzing the
(least significant)
relative importance played by
each bit of the image
• Also useful in image
compression
Bit-plane slicing
• To display a bit-plane of an image with
pixels uniformly quantized to B-bits. Let the
pixel intensity

• Then most significant (B-n)th-bit plane can


be represented as

Where, L = 2B-1
• To understand: if B=8, then L=255
Example
• The (binary) image for bit-
plane-7 can be obtained
by processing the input
image with a thresholding
gray-level transformation.
– Map all levels between 0
and 127 to 0
– Map all levels between 128
and 255 to 255

An 8-bit fractal image


8-bit planes
Bit-plane 8 Bit-plane 7

Bit- Bit- Bit-


plane 6 plane 5 plane 4

Bit- Bit- Bit-


plane 3 plane 2 plane 1
Histogram Processing
• Histogram of a digital image with gray levels in
the range [0,L-1] is a discrete function
h(rk) = nk
• Where
– rk : the kth gray level
– nk : the number of pixels in the image having gray
level rk
– h(rk) : histogram of a digital image with gray levels rk
Example
No. of pixels
6
2 3 3 2 5

4 2 4 3 4

3
3 2 3 5
2
2 4 2 4
1
Gray level
4x4 image
Gray scale = [0,9] 0 1 2 3 4 5 6 7 8 9

Histogram
Normalized Histogram
• dividing each of histogram at gray level rk by the
total number of pixels in the image (M x N size)
p(rk) = nk / MN
• For k = 0,1,…,L-1
• p(rk) gives an estimate of the probability of
occurrence of gray level rk
• The sum of all components of a normalized
histogram is equal to 1
Histogram Processing
• Basic for numerous spatial domain
processing techniques
• Used effectively for image enhancement
• Information inherent in histograms is also
useful in image compression and
segmentation
h(rk) or p(rk)
Example
rk

•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.
Example
•Low-contrast image
histogram is narrow
and centered toward
the middle of the
gray scale

•High-contrast image
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
Histogram Equalization
• As the low-contrast image’s histogram is narrow
and centered toward the middle of the gray
scale, if we distribute the histogram to a wider
range the quality of the image will be improved.
• We can do it by adjusting the probability density
function of the original histogram of the image so
that the probability spread equally
Example
before after Histogram
equalization
Example
before after Histogram
equalization

The quality is not


improved much
because the
original image
already has a
broaden gray-
level scale
Example
No. of pixels
6
2 3 3 2 5

4 2 4 3 4

3
3 2 3 5
2
2 4 2 4
1
Gray level
4x4 image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,9]
histogram
Gray
0 1 2 3 4 5 6 7 8 9
Level(j)
No. of
0 0 6 5 4 1 0 0 0 0
pixels
k

n
j 0
j 0 0 6 11 15 16 16 16 16 16

k nj 6 11 15 16 16 16 16 16
 MN
j 0
0 0 / / / / / / / /
16 16 16 16 16 16 16 16
k nj 3.3 6.1 8.4
s=9 n 0 0 9 9 9 9 9
j 0 3 6 8
Example
No. of pixels
2 3 3 2 6
4 2 4 3 5
4
3 2 3 5 3
2 4 2 4 2
1 Gray level
Input image
0123456789
3 6 6 3 6
5
8 3 8 6 4
3
6 3 6 9
2
3 8 3 8 1
Gray level
Output image 0123456789
Histogram equalization
Exercise
Histogram Equalization
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
Consider the continuous domain

Let pr(r) denote continuous probability density


function of gray-level of input image, r

Let pz(z) denote desired (specified) continuous


probability density function of gray-level of output
image, z

Let s be a random variable with the property

r
s  T ( r )   pr ( w )dw Histogram equalization
0

Where w is a dummy variable of integration


Next, we define a random variable z with the property
z
g( z )   pz ( t )dt  s Histogram equalization
0

Where t is a dummy variable of integration


thus

s = T(r) = G(z)

Therefore, z must satisfy the condition

z = G-1(s) = G-1[T(r)]

Assume G-1 exists and satisfies the condition (a) and (b)
We can map an input gray level r to output gray level z
Procedure Conclusion
1. Obtain the transformation function T(r) by
calculating the histogram equalization of the
input image r
s  T ( r )   pr ( w )dw
0

2. Obtain the transformation function G(z) by


calculating histogram equalization of the
desired density function
z
G ( z )   pz ( t )dt  s
0
Procedure Conclusion
3. Obtain the inversed transformation
function G-1
z = G-1(s) = G-1[T(r)]

4. Obtain the output image by applying the


processed gray-level from the inversed
transformation function to all the pixels in
the input image
Example

Assume an image has a gray level probability density


function pr(r) as shown.

Pr(r)   2r  2 ;0  r  1
pr ( r )  
2  0 ; elsewhere

1 r

 p ( w )dw  1
0
r

0 1 2 r
Example

We would like to apply the histogram specification with


the desired probability density function pz(z) as shown.

Pz(z)
 2z ;0  z  1
2 pz ( z )  
 0 ; elsewhere
1 z

 p ( w )dw  1
z
z 0
0 1 2
Step 1:

Obtain the transformation function T(r)

s=T(r) r
s  T ( r )   pr ( w )dw
0
1 r
  ( 2 w  2 )dw
One to one 0
mapping r
function   w  2w 2
0

0 r
1   r  2r
2
Step 2:

Obtain the transformation function G(z)

z
G ( z )   ( 2w )dw
z
z 2
z 2
0
0
Step 3:

Obtain the inversed transformation function G-1

G( z )  T ( r )
z   r  2r
2 2

z  2r  r 2

We can guarantee that 0  z 1 when 0  r 1


Histogram Specification :Discrete
k
sk  T ( rk )   pr ( r j )
j 0
k nj
 k  0 ,1,2 ,..., L  1
j 0 n
k
G ( z k )   pz ( z i )  s k k  0 ,1,2 ,..., L  1
i 0

z k  G T ( rk )
1

G 1
sk  k  0 ,1,2 ,..., L  1
Example
Consider the 64 X 64 size image histogram as shown below
After histogram equalization
Note
• Histogram specification is a trial-and-error
process
• There are no rules for specifying
histograms, and one must resort to
analysis on a case-by-case basis for any
given enhancement task.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy