Image Enhancement
By
Dr. Pradyut Kumar Biswal
IIIT, Bhubaneswar
Introduction
➢ Enhancement is the process of manipulating an
image so that the result is more suitable than
the original for a specific application.
➢ Image enhancement is the process of making
images more useful.
➢ The reasons for doing this include:
▪ Highlighting interesting detail in images
▪ Removing noise from images
▪ Making images more visually appealing
9/5/2024 Digital Image Processing 2
Image Enhancement Examples
9/5/2024 Digital Image Processing 3
Image Enhancement Examples (cont…)
9/5/2024 Digital Image Processing 4
Image Enhancement Examples (cont…)
9/5/2024 Digital Image Processing 5
Image Enhancement Examples (cont…)
9/5/2024 Digital Image Processing 6
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
9/5/2024 Digital Image Processing 7
Spatial Domain
➢ Various techniques of image enhancement
are:
▪ Point processing
▪ Mask Processing
▪ Histogram based
9/5/2024 Digital Image Processing 8
Point Processing
➢ Image enhancement using point
processing techniques:
▪ Negative images
▪ Increasing or decreasing brightness
▪ Thresholding
▪ Logarithmic transformation
▪ Power law transforms
▪ Grey level slicing
▪ Bit plane slicing
9/5/2024 Digital Image Processing 9
Spatial domain Image Enhancement
➢ Most spatial domain enhancement operations can
be reduced to the form
g (x, y) = T[ f (x, y)]Origin x
➢ where f (x, y) is the
input image, g (x, y) is
the processed image
and T is some
operator defined over (x, y)
some neighbourhood
of (x, y)
y Image f (x, y)
9/5/2024 Digital Image Processing 10
Intensity Transformation
➢ When g depends only on the value of f at a
single point (x,y), T becomes an intensity (also
called a gray-level) transformation function of
the form
➢ Here, s and r denote the intensity of g and f at
any point (x,y) respectively.
➢ These point operations are also called zero
memory operations.
9/5/2024 Digital Image Processing 11
Negative Images
➢ Negative images are useful for enhancing
white or grey detail embedded in dark
regions of an image
▪ Note how much clearer the tissue is in the
negative image of the mammogram
Original Negative
s = 1.0 - r
Image Image
9/5/2024 Digital Image Processing 12
Negative Images
Original Image Enhanced Image x
x
y Image f (x, y) y Image f (x, y)
s = intensitymax – r
S = L -1 - r
9/5/2024 Digital Image Processing 13
Brightness modification
s=r±k Where k is a constant.
Original Image
Increase in Brightness Decrease in Brightness
9/5/2024 Digital Image Processing 14
Brightness modification
Original Image
Increase in Brightness Decrease in Brightness
9/5/2024 Digital Image Processing 15
Thresholding
➢ Thresholding transformations are
particularly useful for segmentation in
which we want to isolate an object of
interest from a background
s
255
128 r
1.0 r > threshold
s=
0.0 r <= threshold
9/5/2024 Digital Image Processing 16
Intensity transformation
Contrast Stretching Thresholding
9/5/2024 Digital Image Processing 17
Basic Gray Level Transformations
➢ There are many different kinds of grey
level transformations
➢ Three of the most
common are:
◼ Linear
Negative/Identity
◼ Logarithmic
Log/Inverse log
◼ Power law
nth power/nth root
9/5/2024 Digital Image Processing 18
Logarithmic Transformations
➢ The general form of the log transformation
is s = c * log(1 + r)
where usually c is set to 1.
➢ The log transformation maps a narrow
range of low input grey level values into a
wider range of output values
➢ The inverse log transformation performs
the opposite transformation
9/5/2024 Digital Image Processing 19
Logarithmic Transformations
9/5/2024 Digital Image Processing 20
Power law transformations
➢ Power law transformations have the
following form
s=c*rγ
➢ 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
9/5/2024 Digital Image Processing 21
Power law transformations
➢ The images show a
magnetic resonance s = r 0.6
(MR) image of a
fractured human
spine
s = r 0.4
➢ Different curves
highlight different
detail
9/5/2024 Digital Image Processing 22
Piecewise Linear Transformation
➢ Rather than using a well defined
mathematical function arbitrary user-
defined transforms can be used.
➢ Contrast stretching linear transform is used
to add contrast to a poor quality image.
9/5/2024 Digital Image Processing 23
Piecewise Linear Transformation
➢ Contrast stretching linear transform can be
expressed as:
s = r, 0 ≤ r ≤ A
= (r-A) + vA A≤ r ≤ B
= (r-B) + vB B≤ r ≤ L-1
9/5/2024 Digital Image Processing 24
Gray level slicing
➢ Highlights a specific range of grey levels
▪ Similar to thresholding
▪ Other levels can be suppressed or maintained
▪ Useful for highlighting features in an image
9/5/2024 Digital Image Processing 25
Gray level slicing
With Background
Without Background
S = L-1, A ≤ r ≤ B S = L-1, A ≤ r ≤ B
= 0, Otherwise = r, Otherwise
9/5/2024 Digital Image Processing 26
Bit Plane Extraction / Bit Slicing
➢ Often by isolating particular bits of the
pixel values in an image we can highlight
interesting aspects of that image
➢ Higher-order bits usually contain most of the
significant visual information
➢ Lower-order bits contain subtle details
9/5/2024 Digital Image Processing 27
Bit Plane Extraction / Bit Slicing
9/5/2024 Digital Image Processing 28
Bit Plane Extraction / Bit Slicing
[10000000] [01000000]
[00100000] [00001000]
[00000100] [00000001]
9/5/2024 Digital Image Processing 29
Bit Plane Extraction / Bit Slicing
9/5/2024 Digital Image Processing 30
Bit Plane Extraction / Bit Slicing
Reconstructed image
using only bit planes 8
and 7
Reconstructed image
using only bit planes 8, 7
and 6
Reconstructed image
using only bit planes 8, 7,
6 and 5
9/5/2024 Digital Image Processing 31
Spatial Filtering
➢ The principal approach for defining spatial
neighborhoods about a point (x, y) is to use a
square or rectangular region centered at (x, y).
9/5/2024 Digital Image Processing 32
Importance of Neighborhood
➢ Both zebras and dalmatians have black and
white pixels in similar numbers.
➢ The difference between the two is the
characteristic appearance of small group of
pixels rather than individual pixel values.
9/5/2024 Digital Image Processing 33
Spatial Filtering
➢ A spatial filter consists of (a) a
neighborhood, and (b) a predefined
operation
➢ Linear spatial filtering of an image of size
MxN with a filter of size mxn is given by
the expression
9/5/2024 Digital Image Processing 34
Spatial Filtering
9/5/2024 Digital Image Processing 35
The Spatial Filtering Process
Origin x
a b c j k l
d
g
e
h
f
i
* m
p
n
q
o
r
Original Filter (w)
Simple 3*3 Image Pixels
e 3*3 Filter
Neighbourhood
eprocessed = n*e + j*a + k*b +
l*c + m*d + o*f + p*g + q*h +
r*i
y Image f (x, y)
The above is repeated for every pixel in the original
image to generate the filtered image
9/5/2024 Digital Image Processing 36
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 37
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 38
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 39
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 40
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 41
Spatial Filtering (Moving Average)
9/5/2024 Digital Image Processing 42
Spatial filters
1.Smoothing Spatial filters [low pass].
2.Sharpening Spatial Filters[high pass].
9/5/2024 Digital Image Processing 43
Spatial filters : Smoothing
➢ The low pass filter preserves the smooth
region in the image and removes sharp
variations leading to blurring effect.
➢ Use: for blurring and noise reduction.
Type of smoothing filters:
1. Standard average linear
2. weighted average.
Order statistics
3. Median filter
9/5/2024 Digital Image Processing 44
Smoothing Spatial Filters
➢ One of the simplest spatial filtering operations
we can perform is a smoothing operation
◼ Simply average all of the pixels in a neighbourhood
around a central value
1/ 1/ 1/
◼ Especially useful 9 9 9 Simple
in removing noise averaging
1/ 1/ 1/
from images 9 9 9 filter
◼ Also useful for 1/ 1/ 1/
highlighting gross 9 9 9
detail
◼ An averaging filter in which all coefficients are equal
also called as box filter.
9/5/2024 Digital Image Processing 45
Smoothing Spatial Filtering
Origin x
104 100 108 1/ 1/ 1/
9 9 9
99 106 98
95 90 85
* 1/
1/
9
1/
1/
9
1/
1/
9
9 9 9
1/ 100108
Original Filter
9 /9 /9
104 1 1
Simple 3*3 /9 1106
199 /9 198
/9
3*3 SmoothingImage Pixels
Neighbourhood /9 190
195 /9 185
/9
Filter
e = 1/9*106 + 1/9*104 + 1/9*100 +
1/ *108 + 1/ *99 + 1/ *98 + 1/ *95 +
9 9 9 9
1/ *90 + 1/ *85 = 98.3333
9 9
y Image f (x, y)
The above is repeated for every pixel in the original
image to generate the smoothed image
9/5/2024 Digital Image Processing 46
Smoothing Spatial Filtering
➢ What happens when the Values of the Kernel Fall Outside the
Image??!
9/5/2024 Digital Image Processing 47
First solution :Zero padding
-ve: black border
9/5/2024 Digital Image Processing 48
2nd solution: border padding
9/5/2024 Digital Image Processing 49
Smoothing Averaging effects
Original image 3 x 3 averaging
5 x 5 averaging 9 x 9 averaging
15 x 15 averaging 35 x 35 averaging
Notice how detail
begins to disappear
9/5/2024 Digital Image Processing 50
Linear smoothing : averaging kernels
weighted average
Used to reduce blurring more.
9/5/2024 Digital Image Processing 51
Spatial Smoothing Linear Filters
➢ The general implementation for filtering an M
× N image with a weighted averaging filter of
size m × n is given
where m=2a+1, n=2b+1.
9/5/2024 Digital Image Processing 52
Order-statistic (Nonlinear) Filters
➢ Nonlinear
➢ Based on ordering (ranking) the pixels
contained in the filter mask
➢ Replacing the value of the center pixel
with the value determined by the
ranking result
➢ E.g., median filter, max filter, min filter,
mid-point filter, alpha-trimmed filter
9/5/2024 Digital Image Processing 53
Median filter
110 120 90 130
becomes
91 94 98 200 95
90 95 99 100
82 96 85 90
Steps:
1. Sort the pixels in ascending order:
90,90, 91, 94, 95, 98, 99, 110, 120
2. replace the original pixel value by the median : 95
9/5/2024 Digital Image Processing 54
Median filter
reduces salt and pepper noise
The original The smoothed The smoothed image
image with salt image using using median
and pepper noise averaging
9/5/2024 Digital Image Processing 55
Median Filtering
➢ Very effective for removing “salt and pepper” noise).
averaging median
filtering
9/5/2024 Digital Image Processing 56
Order Statistic filters (Max)
➢ Median represents 50th percentile of a ranked
set of numbers.
➢ When 100th percentile is considered, is called as
Max filter.
➢ This filter is used to find brightest points in an
image.
➢ Also, as peeper noise has very low values, it
reduces peeper noise.
9/5/2024 Digital Image Processing 57
Order Statistic filters (Min)
➢ When 0th percentile is considered, is called as
Min filter.
➢ This filter is used to find darkest points in an
image.
➢ Also, as salt noise has very high values, it
reduces salt noise.
9/5/2024 Digital Image Processing 58
Order Statistic filters (Midpoint)
➢ The midpoint filter computes the midpoint
between minimum and maximum values in the
area encomposed by the filter.
➢ This filter combines order statistics and
averaging.
➢ It works best for randomly distributed noise like
Gaussian noise or uniform noise.
9/5/2024 Digital Image Processing 59
Order Statistic filters (Alpha Trimmed
mean)
➢ Alpha-trimmed mean filter removes the d/2 highest and
d/2 lowest intensity values. The average of these
remaining mn-d values is called an alpha-trimmed mean
filter.
➢ The value of d can range from 0 to mn-1.
➢ When d=0, this filter reduces to arithmetic mean filter.
➢ When d=mn-1, the filter reduces to median filter.
➢ This is useful for multiple type of noises such as
combination of salt-pepper and Gaussian noise.
9/5/2024 Digital Image Processing 60
Sharpening Spatial Filters (HPF)
➢ The aim is to emphasize the transitions
in intensity.
❖ Laplacian Operator
❖ Unsharp Masking and Highboost Filtering
❖ Using First-Order Derivatives for Nonlinear
Image Sharpening - The Gradient
9/5/2024 Digital Image Processing 61
Sharpening Spatial Filters
➢ The first-order derivative of a one-
dimensional function f(x) is the difference
➢ Any definition for a first derivative:
▪ Must be zero in areas of constant intensity.
▪ Must be nonzero at the onset of an intensity
step or ramp.
▪ Must be nonzero along intensity ramps.
9/5/2024 Digital Image Processing 62
Sharpening Spatial Filters
➢ The second-order derivative of f(x) as the
difference
➢ Any definition of a second derivative
▪ Must be zero in areas of constant intensity.
▪ Must be nonzero at the onset and end of an
intensity step or ramp.
▪ Must be zero along intensity ramps.
9/5/2024 Digital Image Processing 63
Sharpening Spatial Filters
9/5/2024 Digital Image Processing 64
Image Sharpening based on First-Order
Derivatives
➢ For function f(x,y), the gradient of f at
coordinates (x,y) is defined as
➢ The magnitude of vector f, denoted as
M(x,y)
9/5/2024 Digital Image Processing 65
Image Sharpening based on First-Order
Derivatives
➢ The magnitude of vector f, denoted as
M(x,y)
9/5/2024 Digital Image Processing 66
Image Sharpening based on First-Order
Derivatives
3×3 region of an
image
Roberts cross-gradient
operators
9/5/2024 Digital Image Processing 67
Image Sharpening based on First-Order
Derivatives
Sobel operators
9/5/2024 Digital Image Processing 68
Sharpening Spatial Filters: Laplace
Operator
➢ The second-order isotropic derivative operator
is the Laplacian for a function (image) f(x,y). It
is defined as
➢ In the x-direction,
➢ In the y-direction,
9/5/2024 Digital Image Processing 69
Sharpening Spatial Filters: Laplace
Operator
➢ The discrete Laplacian of two variables is
➢ The kernel is
Kernel 1
➢ The kernel is isotropic for rotations in increments
of 90° with respect to the x- and y-axes
9/5/2024 Digital Image Processing 70
Sharpening Spatial Filters: Laplace
Operator
➢ The diagonal directions can be incorporated in
the definition of the digital Laplacian by adding
four more terms.
➢ The kernel becomes
Kernel 2
Kernel 3 Kernel 4
➢ Two other Laplacian
kernels are
9/5/2024 Digital Image Processing 71
Sharpening Spatial Filters: Laplace
Operator
➢ Because the Laplacian is a derivative operator,
it highlights sharp intensity transitions in an
image and de-emphasizes regions of slowly
varying intensities.
➢ This will tend to produce images that have
grayish edge lines and other discontinuities,
all superimposed on a dark, featureless
background.
➢ Background features can be recovered while
still preserving the sharpening effect of the
Laplacian by adding the Laplacian image to
the original.
9/5/2024 Digital Image Processing 72
Sharpening Spatial Filters: Laplace
Operator
➢ Image sharpening in the way of using the
Laplacian:
➢ where f(x,y) and g(x,y) are the input and
sharpened images, respectively.
➢ Let c =−1 if the Laplacian kernels center value is
negative and c = 1 if the Laplacian kernels
center value is positive.
9/5/2024 Digital Image Processing 73
Sharpening Spatial Filters: Laplace
Operator
Laplacian image obtained
using the kernel 1
Blurred Image
Image
sharpened Laplacian image
with c =−1 obtained
using the kernel 2 with
c = -1
9/5/2024 Digital Image Processing 74
Unsharp Masking And Highboost Filtering
➢ This technique is being used since 1930s by
the printing and publishing industry to sharpen
images
➢ Subtracting an unsharp (smoothed) version of
an image from the original image is called
unsharp masking.
➢ It consists of the following steps:
1. Blur the original image.
2. Subtract the blurred image from the
original (the resulting difference is called
the mask.)
3. Add the mask to the original.
9/5/2024 Digital Image Processing 75
Unsharp Masking And Highboost Filtering
➢ Let f(x,y) denote the original image and 𝑓(x,y)
ҧ
denote the blurred image.
➢ The mask is given as
➢ Then, add a weighted portion of the mask back
to the original image
▪ When k = 1, it is called unsharp masking.
▪ When k > 1, the process is referred to as highboost
filtering.
▪ Choosing k < 1 reduces the contribution of the unsharp
mask.
9/5/2024 Digital Image Processing 76
Illustration of the unsharp masking
➢ In this 1D intensity profile
example, a vertical ramp
edge shows the
transitions from dark to
light.
➢ The points at which a
change of slope occurs in
the signal are now
emphasized (sharpened).
9/5/2024 Digital Image Processing 77
Illustration of the unsharp masking
Original Image Blurred Image
Masked Image
Unsharp masking Highboost filtering
with k=1 with k=4.5
9/5/2024 Digital Image Processing 78
Query?
Thanks
9/5/2024 Digital Image Processing 79