You are on page 1of 33

Image Enhancement

Introduction
Image Enhancement : A technique for enhancing/improving visual quality of an
image

Landscape MRI of fractured human spine

‰ Sharpens image features


‰ Inherent information content same
‰ Increase in dynamic range

2
Image Enhancement

Spatial domain Frequency domain

Point operation Window operation

Spatial domain techniques


(x,y)
¾ Performed to the image planes
¾ Direct manipulation of the pixel values

g ( x, y ) T > f ( x, y ) @
f(x,y) : input image
Size of neighborhood: f(x,y)
g(x,y) : output image
T : operator defined over (1 x 1) – point operation
some neighborhood (m x m) – window/mask operation

3
Contrast Stretching
¾ To increase the dynamic range of the input image
L-1 L-1
Output intensity

Output intensity
Limiting case

0, 0 L-1 0, 0
Input intensity Input intensity L-1
L-1
Thresholding
Output intensity

Piece-wise contrast
stretching
Assumption:
Image gray levels : 0 to (L-1)

0, 0 Input intensity L-1

4
Basic Gray Level Transformation
Basic relation between input and output pixel intensity is

s T (r ) r : input image pixel intensity


s : output image pixel intensity
T : transformation function

‰ Linear : identity, negative


‰ Logarithmic : log, inverse log
‰ Power-law : nth power, nth root

5
Basic Gray Level Transformation
Negative : enhancing white details
on black background (x-ray images)

s L 1 r

Mammogram Enhanced image

Log : compressing dynamic range of


image intensity with large variations
(Fourier magnitude spectrum)

s c log(1  r )
Fourier spectrum

6
Basic Gray Level Transformation
Negative : enhancing white details
on black background (x-ray images)

s L 1 r

Mammogram Enhanced image

Log : compressing dynamic range of


image intensity with large variations
(Fourier magnitude spectrum)

s c log(1  r )
Fourier spectrum

7
Basic Gray Level Transformation

Gamma correction (Power-law transformation)


• γ > 1 : bright region stretch
• γ < 1 : dark region stretch

s cr J

Gamma correction:
CRT devices (power law): 1.8-2.5
MRI of fractured human spine (γ=0.3)

8
Gray-level Slicing

• Highlighting a specific
range of gray level in an
image

Example : Aortic angiogram

Results of slicing transformation using both the functions.

9
Histogram Processing
• Modify the input image histogram to improve the contrast.
• Used for Contrast stretching in images with narrow histogram.
• Automatically developed transformation function based on input image histogram.

10
Histogram Equalization
Assumption:
ƒ Image pixel intensity : rk, k=0, 1, 2, …… , L-1
ƒ Image histogram : h(rk)=nk
ƒ Normalized histogram : p(rk)=h(rk)/(M.N)

Modify the input histogram into a uniform histogram.


Let, the transformation is
• T(r) is single valued,
s T (r ) monotonically increasing in [0, 1]
• 0 ≤ T(r) ≤ 1, for 0 ≤ r ≤ 1

Satisfying all the constraints,

k
T (rk ) (L 1)¦ p(rj )
j 0

11
12
0 7 3 2 3
0 0 0 6 7
7 7 2 2 0
1 1 0 4 1
0 0 7 4 1

r p T level
0 8/25 56/25 2
1 4/25 84/25 3
2 3/25 105/25 4
3 2/25 119/25 5
4 2/25 133/25 5
5 0 133/25 5
6 1/25 140/25 6
7 5/25 175/25 7

13
r n1 s n2
0 8 0 0
1 4 1 0
2 3 2 8
3 2 3 4
4 2 4 3
5 0 5 4
6 1 6 1
7 5 7 5

Chart Title
Chart Title 10

10 8
8 6
6
4
4
2 2
0 0
0 2 4 6 8 10 0 2 4 6 8 10

14
Example:
Suppose, 2-bit image (L=4) of size 5 x 4 pixels

rk nk p(rk) T(rk)

No. of pixels
0 4 0.2 0.6→1
1 10 0.5 2.1→2
2 4 0.2 2.7→3
3 2 0.1 3
Input intensity

Equalized histogram: rk nk
0 0
1 4
No. of pixels

2 10
3 6

Input intensity

15
Examples:

Local enhancement using histogram:

Image Subtraction
‰ Used for object/motion tracking, image comparison.
‰ Applications: imaging of blood vessels, security system etc.

16
Image Averaging
A noisy image is
g ( x, y ) f ( x, y )  K ( x, y ) uncorrelated, zero mean noise
Noise reduction by image averaging, M
1
g ( x, y )
M
¦ g ( x, y )
i 1
i

Application: noise removal in satellite images.


Example: Image of Galaxy pair
a) Original image, b) corrupted image with additive zero mean Gaussian noise,
c) averaging with M=64, d) averaging with M=128.

a) b) c) d)
17
Spatial Filtering
y
0,0
• Convolution with the spatial mask of the filter (x,y)
• Computed based on neighborhood values and by
moving the mask from point to point w(s,t)

• Linear filtering of an image f (size M x N) with a


filter mask w (size m x n) is
x
f(x,y)

a b
g ( x, y ) ¦ ¦ w(s, t ) f (x  s, y t),
s  a t b
a (m  1) 2, b (n  1) 2

Applications: noise smoothing, image sharpening etc.

18
Image Smoothing
3 x 3 simple averaging filter 3 x 3weighted averaging filter

ª1 1 1º ª1 2 1 º
1« » 1 « »
w 1 1 1 w 2 4 2
9« » 16 « »
«¬1 1 1»¼ «¬1 2 1 »¼

Gaussian smoothing filter: § ( x 2  y 2 ) ·


h( x, y ) exp ¨ ¸
© 2 V 2
¹
σ determines the amount of smoothing

Applications: noise smoothing, low pass filtering, removal of irrelevant details


Effect: blurring

19
Effect of image smoothing with
different mask size

20
Order Statistics Filters
Non-linear filters:
¾ Median filter : removal of salt and pepper noise, impulse noise
¾ Max filter : finding the brightest point in a neighborhood
¾ Min filter : finding the darkest point in a neighborhood

Example:

Original image Added noise Average Median

21
Image Sharpening
¾ Used to highlight fine details of an image.
¾ Applications : electronic printing, medical imaging, industrial inspection,
autonomous guidance in military systems etc.

Derivative filter
• Enhances edges and other discontinuities (like noise)
• Deemphasizes area with slowly varying intensities
• Zero response at uniform region, non-zero response at the onset of change of
intensity
• 1st order and 2nd order derivatives can be used

22
First order derivative: non zero response at the onset of step or ramp, along
ramp; zero response in flat segments
Second order derivative: zero response in flat segments and along ramp of
constant slope; non zero response at the onset and end of step or ramp,

23
߲݂
ൌ ݂ ‫ ݔ‬൅ ͳ െ ݂ሺ‫ݔ‬ሻ
߲‫ݔ‬

߲ଶ݂
ൌ ݂ ‫ ݔ‬൅ ͳ ൅ ݂ሺ‫ ݔ‬െ ͳሻ െ ʹ݂ሺ‫ݔ‬ሻ
߲‫ ݔ‬ଶ

First order derivative: stronger response to gray level step, produces thicker edges
Second order derivative: stronger response to fine details (thin lines, isolated points),
double response at step changes

24
Laplacian Filter
w2 f w2 f
• Simplest, isotropic derivative operator ’ f 2

wx 2 wy 2
w2 f ª1 1 1º
f ( x  1, y )  f(x  1, y)  2 f ( x, y )
wx 2 w ««1 8 1»»
w2 f
f ( x, y  1)  f(x, y 1)  2 f ( x, y ) «¬1 1 1»¼
wy 2
’2 f f ( x  1, y )  f(x  1, y)  f ( x, y  1)  f(x, y  1)  4 f ( x, y )

North pole of moon


• Highlights gray level discontinuities
and deemphasizes regions with slowly
varying intensities (i.e., dark,
featureless background)
• To recover background while
preserving sharpening effect,

g ( x, y ) f ( x, y )  ’ 2 f ( x, y )

25
Considering four neighbours, Can be written as

ª0 1 0 º ª 0 1 0º
w ««1 4 1 »» w «« 1 4  1 »»
«¬0 1 0 »¼ «¬ 0 1 0 »¼

The composite masks:

ª 0 1 0º ª 1 1 1º
w «« 1 5  1 »» w «« 1 9  1 »»
«¬ 0 1 0 »¼ «¬ 1 1 1»¼

26
Unsharp Masking
Subtract a blurred version of the image from the image itself.

f s ( x, y) f ( x, y )  f ( x, y ) f ( x, y ) : blurred version of f(x,y)

Application : in publishing industry


High-boost filtering
Generalization of unsharp masking
Application : contrast enhancement of dark images (increase in overall intensity)

f hb ( x, y) Af ( x, y )  f ( x, y ), A t 1 Considering Laplacian sharpening


( A  1) f(x, y)  f(x, y)  f ( x, y ) ª0 1 0º
( A  1) f(x, y)  f s ( x, y) w «« 1 A  4  1 »»
«¬ 0 1 0 »¼
27
Gradient – First Derivative
The gradient of an image f(x, y) at coordinate (x, y) is defined as

ª wf º
ª Gx º « wx »
’f «G » « » mag (’f ) [Gx2  G y2 ]1 2
¬ y¼ « wf »
«¬ wy »¼ z1 z2 z3
z4 z5 z6
For 2x2, simplest derivative: Gx:(z8-z5) and Gy: (z6-z5)
For 3x3, |(z7+z8+z9)-(z1+z2+z3)| and |(z3+z6+z9)-(z1+z4+z7)| z7 z8 z9

Different operators for gradient computation:


Robert’s cross-gradient operator

ª 1 0 º ª0 1º
Gx « 0 1 » , Gy «1 0 »
¬ ¼ ¬ ¼

28
Sobel operator
ª 1 2 1º ª 1 0 1 º
Gx « 0 0 0 », G « 2 0 2 »
« » y « »
«¬ 1 2 1 »¼ «¬ 1 0 1 »¼

Prewitt operator ª 1 1 1º ª 1 0 1º


Gx « 0 0 0 », G « 1 0 1»
« » y « »
«¬ 1 1 1 »¼ «¬ 1 0 1»¼

29
Combining Spatial Methods
Depending on specific goal, single method or combination of several methods
is used.
Examples: Enhancement using Laplacian filter Smoothing Laplacian
filter filter
Whole body scan ( bone infection and
tumor detection)

Objective: sharpening, bringing out


more skeletal detail
Challenges: Narrow dynamic range,
high noise content
Steps:
¾ Laplacian (highlight fine details)
¾ Gradient (enhance edges)
¾ Gamma correction (increase
dynamic range)

30
Mask and its size

ª0 0 0 º ª1 1 1º ª0 0 0 º
«0 1 0 » 1« » «0 0 1 »
1 1 1
« » 9« » « »
«¬0 0 0 »¼ «¬1 1 1»¼ «¬0 0 0 »¼

Identity average
ª1 1 2 2 2 1 1º
Gaussian filter: r=3σ (99%) «1 2 2 4 2 2 1 »»
«
or h=w=5σ (98.76%) «2 2 4 8 4 2 2»
« »
«2 4 8 16 8 4 2 »
«2 2 4 8 4 2 2»
« »
V 1.4 «1 2 2 4 2 2 1»
«1 2 2 2 1 1 »¼
¬ 1

31
Filtering operation

Padding : no, zero, same/replicate

Alpha trimmed mean filter:


n x n mask, α
Output=mean of middle (n2- α) values.

Noise size and mask size (median filter):

32
1. An 8-bit input monochrome image is to be enhanced by stretching
graylevel range [86, 124] by a factor 2. The remaining parts of the grayscale
should be compressed at a uniform rate. Derive the gray level
transformation function for the purpose and draw the curve.

2. compute the High-boost filtered image. Consider 3x3 mask, zero padding,
A=1.7 and 4-neighbour Laplacian filter for unsharp masking.
18 20 19 19

21 20 7 18

20 22 21 17

22 4 20 25

33

You might also like