0% found this document useful (0 votes)
16 views54 pages

4 Lecture DIP Image Enhancement Spatial P1 DrTahirNawaz

EE-333 Digital Image Processing covers image enhancement techniques in the spatial domain. Spatial domain enhancement directly manipulates pixel values. Key techniques include intensity transformations like contrast stretching and power-law transformations. Histogram processing is also discussed, including histogram equalization which remaps pixel values to create a uniform histogram for enhanced contrast. Examples are provided to demonstrate spatial domain enhancement methods.

Uploaded by

zain sajid
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)
16 views54 pages

4 Lecture DIP Image Enhancement Spatial P1 DrTahirNawaz

EE-333 Digital Image Processing covers image enhancement techniques in the spatial domain. Spatial domain enhancement directly manipulates pixel values. Key techniques include intensity transformations like contrast stretching and power-law transformations. Histogram processing is also discussed, including histogram equalization which remaps pixel values to create a uniform histogram for enhanced contrast. Examples are provided to demonstrate spatial domain enhancement methods.

Uploaded by

zain sajid
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/ 54

EE-333 Digital Image Processing

Image Enhancement in Spatial Domain

Dr Tahir Nawaz
Website: https://www.tahirnawaz.com
Email: [email protected]
Image enhancement

Original image Enhanced image


Image enhancement

Original image Enhanced image


Image enhancement
• Processing an image so that the result is more suitable
and improved than the original image for a specific
application.

• Image Enhancement Methods


– Spatial Domain: Direct manipulation of pixels in an
image
– Frequency Domain: Process the image by modifying
the Fourier transform of an image

• This Lecture – Spatial Domain


Types of image enhancement operations
• Point/Pixel operations
– Output value at specific
coordinates (x,y) is
dependent only on the input
value at (x,y)
• Local operations
– The output value at (x,y) is
dependent on the input
values in the neighborhood of
(x,y)
• Global operations
– The output value at (x,y) is
dependent on all the values
in the input image
Processing in spatial domain
• Most spatial domain enhancement operations can be
generalized as:

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

• f(x, y) = the input image

• g(x, y) = the processed/output image

• T = an operator defined over some neighborhood of (x,y)


Processing in spatial domain
Intensity or mapping transformation
• The most simplest form of T is when the neighborhood is
1x1, i.e. single pixel.
• s = T(r)
– For simplicity, r and s are variables denoting gray level of f(x,y)
and g(x,y), respectively, at any point (x,y)
Intensity or mapping transformation
• Segmentation of an object of interest from a background
Intensity or mapping transformation
• Intensity scaling
s = T(r) = a.r
Basic gray-level transformations
• Some basic intensity transformation functions. All curves
are scaled to fit in the range shown.
Basic gray-level transformations
• Image Negatives
– Reverses the gray level order
– For L gray levels, the transformation has the form:
s = (L - 1) - r
– Negative images are useful for enhancing white or grey detail
embedded in dark regions of an image
Basic gray-level transformations
• Log Transformations
– The general form of the log
transformation is
s = c log (1 + r)
– The log transformation maps a
narrow(wider) range of
low(high) input grey level
values into a wider(narrower)
range of output values
– For lower amplitudes of input
image the range of gray levels
is expanded
– For higher amplitudes of input
image the range of gray levels
is compressed
– The inverse log transformation performs the opposite
transformation
Basic gray-level transformations
• Log Transformations
– This transformation is suitable for the case when the dynamic
range of a processed image far exceeds the capability of the
display device (e.g. display of the Fourier spectrum of an image)
– It is also called “dynamic-range compression/expansion”
Basic gray-level transformations
• Power-Law Transformations
– Power law transformations
have the following form
s=crƔ
– Map a narrow range of dark
input values into a wider range
of output values or vice versa
– Varying Ɣ gives a whole family
of curves

• For Ɣ < 1: Expands values of dark pixels, compress


values of brighter pixels
• For Ɣ > 1: Compresses values of dark pixels, expand
values of brighter pixels
• If Ɣ = 1 & c = 1: Identity transformation (s = r)
Basic gray-level transformations
• Power-Law Transformations
– Result of contrast enhancement
Basic gray-level transformations
• Power-Law Transformations
– Reducing Ɣ too much leads to a wash-out appearance in an
image
Basic gray-level transformations
• Power-Law Transformations
– Image enhancement
Basic gray-level transformations
• Piecewise-Linear Transformations
– A complementary approach to the methods discussed in the
previous three transformations is to use piecewise linear
functions

– Contrast stretching

– Intensity-level slicing
Basic gray-level transformations
• Piecewise-Linear
Transformations
– Contrast stretching
• Increase the dynamic
range of the gray levels
for low contrast images
• Rather than using a well
defined mathematical
function, we divide it
into piecewise linear
segments
Basic gray-level transformations
• Piecewise-Linear Transformations
– Contrast stretching
Basic gray-level transformations
• Piecewise-Linear Transformations
– Gray-level slicing
• It involves highlighting or enhancing a specific range of gray levels
Basic gray-level transformations
• Piecewise-Linear Transformations
– Gray-level slicing
Histogram processing
• Let I be a grayscale image

• I(r,c) stores an 8-bit integer (intensity value) between 0


and 255

• Histogram, hI, of I:
– a 256-element array, hI
– hI (g) = number of pixels in I that have the value g
– where g = 0,1, 2, 3, …, 255
Histogram processing
• More formally, we can define histogram in the form of a
discrete function as follows:
h(rk)=nk,
where rk is the kth gray level value and nk is the number
of pixels having gray level value rk in the image
Histogram processing
• Actually we can have exactly the same histogram of two
different images too!
Histogram processing
• Histogram of a grayscale image
Histogram processing
• Histogram of a grayscale image
Histogram processing
• Histogram of a colored image
– In the case of colored image, I has got three channels

– I(r,c,R), I(r,c,G), and I(r,c,B) are integer values between


0 and 255.

– I actually has 3 histograms:


• hR(g)= # of pixels in I(:,:,1) with intensity value g
• hG(g) = # of pixels in I(:,:,2) with intensity value g
• hB(g) = # of pixels in I(:,:,3) with intensity value g
Histogram processing
• Histogram of a colored image
Histogram processing
• Examples
Histogram processing
• Examples
Histogram processing
• Examples
Histogram processing
• Examples
Histogram equalization
• Histogram equalization re-assigns the intensity values of
pixels in the input image such that the output image
contains a uniform distribution of intensities
Histogram equalization
Histogram equalization
• Aerial photograph of Pentagon
Histogram equalization
• Probability Distribution Function (pdf) of an image
Histogram equalization
• p(g) is the fraction of pixels in an image that have
intensity value g, or more formally, it is the probability
that a pixel randomly selected from the given image has
intensity value g.

• Whereas the sum of the histogram h(g) over all g from 0


to 255 is equal to the number of pixels in the image, the
sum of p(g) over all g is 1.

• pI(g) is the normalized histogram of the image


Histogram equalization
• The Cumulative Distribution Function (CDF) of an image
– Let ɣ = I(r,c) be the value of a randomly selected pixel from I. Let
g be a specific gray level. The probability that ɣ ≤ g is given by:

– where hI(ɣ) is the histogram of image I.


Histogram equalization
• P(g) is the fraction of pixels in an image that have
intensity values less than or equal to g, or more formally,
it is the probability that a pixel randomly selected from
the given band has an intensity value less than or equal
to g.

• P(g) is the cumulative (or running) sum of p(g) from 0


through g inclusive.

• P(0) = p(0) and P(255) = 1


Histogram equalization
• We employ CDF (PI(g)) to perform histogram
equalization of an image I

• Task: to remap image I so that its histogram is as close


to constant as possible

• We could achieve the above task by using CDF as the


look-up table LUT
Histogram equalization
Histogram equalization
Histogram equalization
Histogram equalization
Histogram equalization
• Implementation
Histogram equalization
• Example
Histogram equalization
• Example
cdf

s = round(255 x 0.719) = 183

183
Histogram equalization
• Example
Histogram equalization
• Example
Histogram equalization
• Example
Histogram equalization
• Example
Acknowledgement/References
• Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods,
Addison-Wesley, 2002
• Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22)
2000
• Pattern Recognition and Analysis Course – A.K. Jain, MSU
• “Pattern Classification” by Duda et al., John Wiley & Sons.
• “Machine Vision: Automated Visual Inspection and Robot Vision”,
David Vernon, Prentice Hall, 1991
• www.eu.aibo.com/
• Advances in Human Computer Interaction, Shane Pinder, InTech,
Austria, October 2008
• https://www.cs.nmt.edu/~ip/lectures.html
• https://web.stanford.edu/class/ee368/handouts.html

You might also like