Вы находитесь на странице: 1из 85

Digital Image Processing

Image Transforms

Department of Electronics & Telecommunication Engineering


SGI, Atigre
What Is Image Enhancement?

• 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


Image Enhancement Examples
Image Enhancement Examples (cont…)
Image Enhancement Examples (cont…)
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
Basic Spatial Domain Image
Enhancement
• Most spatial domain enhancement operations can be
reduced to the form
g (x, y) = T[ f (x, y)] Origin y

• where f (x, y) is the


input image, g (x, y) is
the processed image
and T is some
(x, y)
operator defined over
some neighbourhood
of (x, y)

x Image f (x, y)
Point Processing
• The simplest spatial domain operations occur when
the neighbourhood is simply the pixel itself
• In this case T is referred to as a grey level
transformation function or a point processing
operation
• Point processing operations take the form
s=T(r)
• where s refers to the processed image pixel value
and r refers to the original image pixel value
Point Processing Example:
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 below

Original Negative
Image s = 1.0 - r Image

Image Negation
Point Processing Example:
Negative Images
Original Image Enhanced Image y
y

x Image f (x, y) x Image f (x, y)

s = intensitymax - r
Point Processing Example:
Thresholding
• Thresholding transformations are particularly useful for
segmentation in which we want to isolate an object of
interest from a background

1.0 r > threshold


s=
0.0 r <= threshold

Image Thresholding
Point Processing Example:
Thresholding (cont…)
Original Image Enhanced Image y
y

x Image f (x, y) x Image f (x, y)

1.0 r > threshold


s=
0.0 r <= threshold
Intensity Transformations
Basic Grey Level Transformations
• There are many different kinds of grey level
transformations
• Three of the most
common are shown
here
• Linear
• Negative/Identity
• Logarithmic
• Log/Inverse log
• Power law
• nth power/nth root
Logarithmic Transformations

• The general form of the log transformation is


s = c * log(1 + r)

• 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
Logarithmic Transformations (cont…)
• Log functions are particularly useful when the input grey
level values may have an extremely large range of values
• In the following example the Fourier transform of an
image is put through a log transform to reveal more
detail

s = log(1 + r)

Log Transformation
Logarithmic Transformations (cont…)
Original Image Enhanced Image y
y

x Image f (x, y) x Image f (x, y)

s = log(1 + r)
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
Power Law Transformations (cont…)
Original Image Enhanced Image y
y

x Image f (x, y) x Image f (x, y)

s=rγ
• We usually set c to 1
• Grey levels must be in the range [0.0, 1.0]
Power Law Example
Power Law Example (cont…)

γ = 0.6
1
Transformed Intensities

0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Old Intensities
Power Law Example (cont…)
Power Law Example (cont…)

γ = 0.4
1
0.9
Transformed Intensities

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
Power Law
Power Law Example Example (cont…)
(cont…)

γ = 0.3
1
0.9
Transformed Intensities

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
Power Law Example (cont…)
• The images to the
right show a
magnetic resonance s = r 0.6
(MR) image of a
fractured human
spine

s = r 0.4
• Different curves
highlight different
detail

Power Law Transformation


Power Law Example
Power Law Example (cont…)

γ = 5.0
1
0.9
Transformed Intensities

0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
Power Law Transformations (cont…)
• An aerial photo
of a runway is
shown s = r 3.0
• This time
power law
transforms are

s = r 4.0
used to darken
the image
• Different curves
highlight
different detail
Gamma Correction
• Many of you might be familiar with gamma
correction of computer monitors
• Problem is that
display devices do
not respond linearly
to different
intensities
• Can be corrected
using a log
transform
Piecewise Linear Transformation
Functions
• Rather than using a well defined mathematical function
we can use arbitrary user-defined transforms
• The images below show a contrast stretching linear
transform to add contrast to a poor quality image

Contrast Stretching
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


Gray Level Slicing

Two Level Gray (Intensity) Level Slicing


Gray Level Slicing

Two Level Gray (Intensity) Level Slicing


Bit Plane 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 minute details
Bit Plane Slicing (cont…)

[10000000] [01000000]

[00100000] [00001000]

[00000100] [00000001]
Bit Plane Slicing (cont…)

Bit Plane Slicing


Bit Plane Slicing (cont…)

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 7, 6
and 5
Image Histograms
• The histogram of an image shows us the distribution of
grey levels in the image
• Massively useful in image processing, especially in
segmentation
Frequencies

Grey Levels
Histogram Examples
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)
Histogram Examples (cont…)

• A selection of images and


their histograms

• Notice the relationships


between the images and
their histograms

• Note that the high contrast


image has the most
evenly spaced histogram
Image Enhancement: Histogram Based
Methods

The histogram of a digital image with gray values r0 , r1 ,, rL1


is the discrete function
nk
p (rk ) 
n
nk: Number of pixels with gray value rk
n: total Number of pixels in the image

The function p(rk) represents the fraction of the total number


of pixels with gray value rk.
Image Enhancement: Histogram Based
Methods
 Histogram provides a global description of the
appearance of the image.
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 are uniformly distributed in [0, 1].

 Let us assume for the moment that the input image to


be enhanced has continuous gray values.

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


based on the histogram of the input image, which will
enhance the image.
Histogram Equalization
The intensity levels in an image may be viewed as
random variables in the interval [0, L-1].
Let pr ( r ) and ps ( s ) denote the probability density
function (PDF) of random variables r and s.
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.
Histogram Equalization

T (r ) is continuous and differentiable.

ps (s)ds  pr (r )dr
Histogram Equalization
r
s  T (r )  ( L  1) pr (w)dw
0

ds dT (r ) d  r 
dr

dr
 ( L  1)

dr  0
pr ( w) dw

 ( L  1) pr (r )

pr (r )dr pr (r ) pr (r ) 1
ps ( s)    
ds  ds   ( L  1) pr (r )  L  1
 
 dr 
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
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 ps(sk) for each sk.
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
Steps for Histogram Equalisation
• Find the running sum of histogram values

• Normalize the values in above step by total number


of pixels

• Multiply the values in above step by maximum gray


level value and then round-off

• Map the gray level values to the result in above


step using one to one correspondence
Histogram Equalisation Example

• Find the running sum of histogram values


Histogram Equalisation Example
• Normalize the values in previous step by total number of pixels

• Multiply the values in above step by maximum gray level value and then round-off
Histogram Equalisation Example
• Map the gray level values to the result in previous step using one to one
correspondence
Histogram Equalisation Example
Histogram Equalization

Histogram Equalization
Equalisation Transformation Function
Equalisation Examples
1
Equalisation Transformation Functions

The functions used to equalise the images in the


previous example
Equalisation Examples
2
Equalisation Transformation Functions

The functions used to equalise the images in the


previous example
Equalisation Examples (cont…)
3

4
Is histogram equalization always good?

• Histogram equalization may not always produce


desirable results, particularly if the given histogram
is very narrow.

• It can produce false edges and regions.

• It can also increase image “graininess” and


“patchiness.”
Is histogram equalization always good?
Histogram Specification
(Histogram Matching)

Histogram equalization yields an image whose pixels


are (in theory) uniformly distributed among all gray
levels.

We may want a transformation that yields an output


image with a pre-specified histogram.

This technique is called histogram specification.


Histogram Specification
(Histogram Matching)
Given Information

(1) Input image from which we can compute its


histogram
(2) Desired histogram.
Goal
Derive a point operation, H(r), that maps the input
image into an output image that has the user-
specified histogram.
Histogram Specification
(Histogram Matching)

z=G-1(T(r))
z s r
desired uniform input
z=G-1(s) s=T(r)
histogram
equalization

histogram
equalization

s=G(z)
Histogram Matching: Procedure

• Obtain pr(r) from the input image and then obtain the
values of s r
s  ( L  1) pr (w)dw
0

• Use the specified PDF and obtain the transformation


function G(z)
z
G( z )  ( L  1)  pz (t )dt  s
0

• Mapping from s to z

z  G 1 (s)
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the
values of sk, round the value to the integer range [0, L-
1]. k k
( L  1)
sk  T (rk )  ( L  1) pr (rj )   nj
j 0 MN j 0

• Use the specified PDF and obtain the transformation


function G(zq), round the value to the integer range [0,
q
L-1].
G ( zq )  ( L  1) pz ( zi )  sk
i 0

• Mapping from sk to zq

zq  G 1 (sk )
Example: Histogram Matching
Example: Histogram Matching
Obtain the scaled histogram-equalized values,

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.
Compute all the values of the transformation function G,
0
G( z0 )  7 pz ( z j )  0.00 0
j 0

G ( z1 )  0.00 0 G ( z2 )  0.00  0
G ( z3 )  1.05 1 G ( z4 )  2.45  2
G ( z5 )  4.55  5 G ( z6 )  5.95  6
G ( z7 )  7.00  7

79
Example: Histogram Matching
Original image and its histogram

Histogram specified image and its histogram


Arithmetic Operations on Image

• Addition
• Used for superimposing one image on another
• Used to remove noise

Addition operation on Image

• Subtraction
• Used to detect the change

Subtraction operation on Image


Arithmetic Operations on Image

• Multiplication
• Masking operation which can be used for background
suppression

Multiplication operation on Image

• Division
• Background suppression

Division operation on Image


Logical Operations on Images

• Logical operations can be performed on binary


images only
• The operations can be ANDing, Oring, NOT and
XORing

Logical operations on Image


• The Fourier sine transform of f (t), sometimes denoted by either or , is
• If t means time, then ν is frequency in cycles per unit time, but in the abstract, they
can be any pair of variables which are dual to each other

Вам также может понравиться