Você está na página 1de 75

PSD2B

Digital Image Processing

Unit I -V
TM

Syllabus- Unit 1

• Introduction
• Steps in Image Processing
• Image Acquisition
• Representation
• Sampling & Quantization
• Relationship between pixels
• Color Models
• Basics of Color Image Processing

PSD2B- Digital Image Processing 2


TM

What is a Digital Image ?


A digital image is a representation of a two-dimensional
image as a finite set of digital values, called picture elements
or pixels

•Pixel values typically represent gray levels, colours, heights,


opacities etc
•Remember digitization implies that a digital image is an
approximation of a real scene

1 pixel

PSD2B- Digital Image Processing 3


TM

What is Digital Image Processing?

•Digital image processing focuses on two major tasks

– Improvement of pictorial information for human interpretation

– Processing of image data for storage, transmission and


representation for autonomous machine perception

PSD2B- Digital Image Processing 4


TM

Digital Image

Digital image = a multidimensional


array of numbers (such as intensity
image)
or vectors (such as color image)

Each component in the image 10 10 16 28


called pixel associates with  9 65
6
70 56 43
26 3756 78
 3299 96 67 
54 70
the pixel value (a single number in 
15 25  67
6013902296
the case of intensity images or a  21 54 47 42 
32 158587853943 92
vector in the case of color images). 54 65 65 39 
32 65 87 99
PSD2B- Digital Image Processing 5
Fundamentals of DIP TM

Origin

y
Image “After snow storm” f(x,y)
An image: a multidimensional function of spatial coordinates.
 Spatial coordinate: (x,y) for 2D case such as photograph,
(x,y,z) for 3D case such as CT scan images
(x,y,t) for movies
 The function f may represent intensity (for monochrome images)
or color (for color images) or other associated values

PSD2B- Digital Image Processing 6


Digital Image TM

Acquisition Process

PSD2B- Digital Image Processing 7


Conventional Coordinate for TM

Image Representation

PSD2B- Digital Image Processing 8


TM

Sampling and Quantization


Generating a Digital Image Sampling

Image sampling: discretize an image in the spatial domain


Spatial resolution / image resolution: pixel size or number of pixels

PSD2B- Digital Image Processing 9


TM

Image Quantization
Image quantization:
discretize continuous pixel values into discrete numbers

Color resolution/ color depth/ levels:


- No. of colors or gray levels or

- No. of bits representing each pixel value

- No. of colors or gray levels Nc is given by

Nc  2 b

where b = no. of bits

PSD2B- Digital Image Processing 10


TM

Relationship between Pixels


(0,0) x

(x-1,y-1) (x,y-1) (x+1,y-1)

(x-1,y) (x,y) (x+1,y)


y

(x-1,y+1) (x,y+1) (x+1,y+1)

Conventional indexing method


PSD2B- Digital Image Processing 11
TM

Neighbors of a Pixel
Neighborhood relation is used to tell adjacent pixels. It is
useful for analyzing regions.

(x,y-1) 4-neighbors of p:

(x1,y)
(x-1,y) p (x+1,y)
(x+1,y)
(x,y1)
N4(p) = (x,y+1)
(x,y+1)

4-neighborhood relation considers only vertical and


horizontal neighbors.

Note: q N4(p) implies p N4(q)


PSD2B- Digital Image Processing 12
8 Neighbors of a pixel TM

(x-1,y-1) (x,y-1) (x+1,y-1) 8-neighbors of p:

(x1,y1)
(x-1,y) p (x+1,y)
(x,y1)
(x+1,y1)
(x1,y)
(x-1,y+1) (x,y+1) (x+1,y+1) (x+1,y)
N8(p) = (x1,y+1)
(x,y+1)
(x+1,y+1)

8-neighborhood relation considers all neighbor pixels.

PSD2B- Digital Image Processing 13


TM

Connectivity

Connectivity is adapted from neighborhood relation.


Two pixels are connected if they are in the same class (i.e. the
same color or the same range of intensity) and they are
neighbors of one another.

For p and q from the same class


 4-connectivity: p and q are 4-connected if q N4(p)

 8-connectivity: p and q are 8-connected if q N8(p)

 mixed-connectivity (m-connectivity):
p and q are m-connected if q N4(p) or
q ND(p) and N4(p) N4(q) = 

PSD2B- Digital Image Processing 14


Color Models TM

• Color model, color space, color system


– Specify colors in a standard way
– A coordinate system that each color is represented by a single point

• RGB model
• CYM model
• CYMK model
• HSI model

PSD2B- Digital Image Processing 15


RGB Color Model
TM

Pixel depth: the number of bits used to represent each pixel in RGB space
Full-color image: 24-bit RGB color image
(R, G, B) = (8 bits, 8 bits, 8 bits)

PSD2B- Digital Image Processing 16


TM

Color Fundamentals

3 basic qualities are used to describe the quality of a chromatic light


source:

Radiance: the total amount of energy that flows from the light
source (measured in watts)

Luminance: the amount of energy an observer perceives from the


light source (measured in lumens)
Note we can have high radiance, but low luminance

Brightness: a subjective (practically unmeasurable) notion that


embodies the intensity of light

PSD2B- Digital Image Processing 17


TM

Syllabus : Unit 2

• Image Enhancement in spatial domain

• Some Basic Gray level transformations

• Histogram Processing

• Basics of spatial filtering and smoothing

PSD2B- Digital Image Processing 18


TM

Image Enhancement

Image Enhancement: is the process that improves the


quality of the image for a specific application
Some Examples of enhancement process are:
Contrast enhancement, Edge enhancement, noise filtering,
sharpening, magnifying etc.

PSD2B- Digital Image Processing 19


Image Enhancement in the TM

Spatial Domain
Spatial Domain Methods (Image Plane) Techniques are based on
direct manipulation of pixels in an image
Spatial domain refers to the aggregate of pixels composing an image.
Spatial domain methods are procedures that operate directly on
these pixels. Spatial domain processes will be denoted by the
expression:
g(x,y) = T [f(x,y)]

Where f(x,y) in the input image, g(x,y) is the processed


image and T is as operator on f, defined over some neighborhood of
(x,y)

In addition, T can operate on a set of input images.

PSD2B- Digital Image Processing 20


TM

Image Enhancement
(Spatial Domain)
The simplest form of T, is when the
neighborhood of size 1X1 (that is a single
pixel). In this case, g depends only on the
value of f at (x,y), and T becomes a gray-
level (also called intensity or mapping)
transformation function of the form:
s = T (r)

Where, for simplicity in notation, r


and s are variables denoting, respectively,
the gray level of f(x,y) and g(x,y) at any
point (x,y)

PSD2B- Digital Image Processing 21


TM

Examples of Enhancement
Techniques- Contrast
Streching
Contrast Stretching
A simple image enhancement technique that
improves the contrast in an image by „stretching‟
the range of intensity values it contains to span
a desired range of values.

PSD2B- Digital Image Processing 22


TM

Examples of Enhancement
Techniques- Thresholding

Thresholding
Is a limited case of contrast stretching, it
produces a two-level (binary) image.

PSD2B- Digital Image Processing 23


TM

Basic Gray Level Transformations

PSD2B- Digital Image Processing 24


TM

Histogram Processing
Histogram based Enhancement

Histogram of an image represents the relative frequency


of occurrence of various gray levels in the image

3000

2500

2000

1500

1000

500

0
0 50 100 150 200

PSD2B- Digital Image Processing 25


TM

Why Histogram?
4
x 10

3.5

2.5
Histogram information
2 reveals that image is
1.5

1 under-exposed
0.5

0 50 100 150 200 250

7000

6000

5000

4000

3000
Over-exposed
2000
image
1000

0 50 100 150 200 250

PSD2B- Digital Image Processing 26


TM

Histogram Equalization

before after
3000 3000

2500 2500

2000 2000

1500 1500

1000
1000

500
500

0
0 50 100 150 200 0
0 50 100 150 200 250 300

before after
equalization equalization
PSD2B- Digital Image Processing 27
TM

Spatial Filtering
The Spatial Filtering Process

a b c j k l
d e f m n o
g h i p q r
Original Image Filter (w)
Pixels

eprocessed = n*e +
j*a + k*b + l*c +
m*d + o*f +
p*g + q*h + r*i
The above is repeated for every pixel in the original image to generate the
filtered image
PSD2B- Digital Image Processing 28
TM

Spatial Filtering :Equation Form

a b
g ( x, y )    w(s, t ) f ( x  s, y  t )
s   at   b

Filtering can be given in equation


form as shown above
Notations are based on the image
shown to the left

PSD2B- Digital Image Processing 29


TM

Smoothing
Image smoothing is used for two primary purposes:
To give an image a softer or special effect
To eliminate noise

Smoothing Spatial Filters

1/ 1/ 1/
9 9 9
1/ 1/ 1/
9 9 9
1/ 1/ 1/ Simple averaging filter
9 9 9

1/ 2/ 1/
16 16 16 Weighted averaging
2/ 4/ 2/ filter
16 16 16
1/ 2/ 1/
16 16 16
PSD2B- Digital Image Processing 30
TM

Effect of using Filters

Original Image Image After Image After


With Noise Averaging Filter Median Filter
Filtering is often used to remove noise from images
Sometimes a median filter works better than an averaging filter

PSD2B- Digital Image Processing 31


TM

Smoothing filters: Gaussian

PSD2B- Digital Image Processing 32


TM

Smoothing Median Filtering

• Very effective for removing “salt and pepper” noise (i.e., random
occurrences of black and white pixels).

median
averaging filtering

PSD2B- Digital Image Processing 33


TM

Syllabus: Unit 3
• Image Enhancement in Frequency Domain

•Introduction to Fourier Transform

•1-D, 2-D DFT & Inverse transform

•Smoothing and Sharpening Filters

PSD2B- Digital Image Processing 34


TM

Image Enhancement in the


Frequency Domain
• The frequency domain refers
to the plane of the two
dimensional discrete Fourier
transform of an image.

• The purpose of the Fourier


transform is to represent a
signal as a linear combination of
sinusoidal signals of various
frequencies.

PSD2B- Digital Image Processing 35


TM

Fourier Transform
Any function that periodically repeats itself can be
expressed as the sum of sines and/or cosines of different
frequencies, each multiplied by a different coefficient
(Fourier series).

Even functions that are not periodic (but whose area


under the curve is finite) can be expressed as the integral
of sines and/or cosines multiplied by a weighting function
(Fourier transform).

PSD2B- Digital Image Processing 36


TM

1D Fourier Transform

• The one-dimensional Fourier transform and its inverse


– Fourier transform (discrete case) DTC
M 1
1
F (u ) 
M
 f ( x )e
x 0
 j 2ux / M
for u  0,1,2,...,M  1

– Inverse Fourier transform:


M 1
f ( x)   F (u )e j 2ux / M for x  0,1,2,...,M  1
u 0

PSD2B- Digital Image Processing 37


TM

2D Fourier Transform

• The two-dimensional Fourier transform and its inverse


– Fourier transform (discrete case) DTC
M 1 N 1
1
F (u , v) 
MN

x 0 y 0
f ( x, y )e  j 2 ( ux / M  vy / N )

for u  0,1,2,...,M  1, v  0,1,2,..., N  1


– Inverse Fourier transform:
M 1 N 1
f ( x, y )   F (u , v)e j 2 ( ux / M  vy / N )
u 0 v 0

for x  0,1,2,...,M  1, y  0,1,2,..., N  1


• u, v : the transform or frequency variables
• x, y : the spatial or image variables

PSD2B- Digital Image Processing 38


TM

2D DFT and its inverse

The 2D DFT F(u,v) can be obtained by


1. taking the 1D DFT of every row of image f(x,y), F(u,y),
2. taking the 1D DFT of every column of F(u,y)

(a)f(x,y) (b)F(u,y) (c)F(u,v)

PSD2B- Digital Image Processing 39


TM

Basics of filtering in the


frequency domain

PSD2B- Digital Image Processing 40


TM

Some Basic Filters & their


Functions

Lowpass filter

Highpass filter

PSD2B- Digital Image Processing 41


TM

Smoothing Frequency Domain Filters


The basic model for filtering in the frequency domain

where F(u,v): the Fourier transform of the image to be


smoothed
H(u,v): a filter transfer function

Smoothing is fundamentally a lowpass operation in the


frequency domain.

There are several standard forms of lowpass filters (LPF).


Ideal lowpass filter
Butterworth lowpass filter
Gaussian lowpass filter

PSD2B- Digital Image Processing 42


TM

Ideal Low Pass Filters

• The simplest lowpass filter is a filter that “cuts off” all high-
frequency components of the Fourier transform that are at a
distance greater than a specified distance D0 from the origin of
the transform.
• The transfer function of an ideal lowpass filter
1 if D(u, v)  D0
H (u, v)  
0 if D(u, v)  D0
where D(u,v) : the distance from point (u,v) to the center of
ther frequency rectangle

 
1
D(u , v)  (u  M / 2)  (v  N / 2)
2 2 2

PSD2B- Digital Image Processing 43


TM

Ideal Low Pass Filters

PSD2B- Digital Image Processing 44


TM

Sharpening Frequency Domain Filter


H hp (u , v)  H lp (u , v)
Ideal highpass filter

0 if D(u, v)  D0
H (u, v)  
1 if D(u, v)  D0

Butterworth highpass filter


1
H (u , v) 
1  D0 / D(u, v)
2n

Gaussian highpass filter

 D2 (u ,v ) / 2 D02
H (u, v)  1  e

PSD2B- Digital Image Processing 45


TM

Syllabus – Unit 4

• Image restoration
• Model of degradation and restoration
process
• noise models
• restoration in the presence of noise
• periodic noise reduction
•Image segmentation
•Thresholding
• Region based segmentation.

PSD2B- Digital Image Processing 46


TM

Image Restoration
• Goal of image restoration

– Improve an image in some predefined sense


– Difference with image enhancement ?

• Features

– Image restoration v.s image enhancement


– Objective process v.s. subjective process
– A prior knowledge v.s heuristic process
– A prior knowledge of the degradation phenomenon is
considered
– Modeling the degradation and apply the inverse process to
recover the original image

PSD2B- Digital Image Processing 47


TM

Model of Degradation & Restoration Process

g(x,y)=f(x,y)*h(x,y)+h(x,y)
G(u,v)=F(u,v)H(u,v)+N(u,v)
PSD2B- Digital Image Processing 48
TM

Noise Models

• Source of noise
– Image acquisition (digitization)
– Image transmission
• Spatial properties of noise
– Statistical behavior of the gray-level values of pixels
– Noise parameters, correlation with the image
• Frequency properties of noise
– Fourier spectrum
– Ex. white noise (a constant Fourier spectrum)

PSD2B- Digital Image Processing 49


TM

Noise probability
density functions
Noises are taken as random variables
Random variables
Probability density function (PDF)

Gaussian Noise
• Math. tractability in spatial and frequency domain
• Electronic circuit noise and sensor noise
1
p( z )  e  ( z   ) / 2
2 2

2 

mean
variance

Note:


p ( z )dz  1

PSD2B- Digital Image Processing 50


Other Noise Models TM

• Impulse (salt-and-pepper) noise


Quick transients, such as faulty switching during imaging
• Periodic Noise -Arise from electrical or electromechanical interference
during image acquisition

PSD2B- Digital Image Processing 51


Restoration in the Presence
TM

of Noise
Mean Filters

ˆf ( x, y )  1
Arithmetic Mean
 g ( s, t )
mn ( s ,t )S xy

Geometric Mean
1/ mn
ˆf ( x, y)    g (s, t )
( s ,t )S xy 
 

PSD2B- Digital Image Processing 52


TM

Mean Filters

• Harmonic mean filter


mn
fˆ ( x, y ) 
1

( s ,t )S xy g ( s, t )

• Contra-harmonic mean filter

 g ( s ,
( s ,t )S xy
t ) Q 1
Q=-1, harmonic
fˆ ( x, y ) 
 g ( s, t ) Q Q=0, airth. mean
( s ,t )S xy Q=+, ?
PSD2B- Digital Image Processing 53
TM

Pepper Salt
Noise Noise

Contra-
Contra- harmonic
harmonic Q=-1.5
Q=1.5
PSD2B- Digital Image Processing 54
TM

Uniform noise Left +


Bipolar Noise
0
Pa = 0.1
2800
Pb = 0.1

5x5
5x5 Geometric
Arith. Mean mean
filter
5x5
5x5
Median Alpha-trim.
Filter
filter
d=5
PSD2B- Digital Image Processing 55
TM

Periodic Noise Reduction

• Pure sine wave


– Appear as a pair of impulse (conjugate) in the
frequency domain

f ( x, y )  A sin( u0 x  v0 y )
A u0 v0 u0 v0 
F (u, v)   j  (u  , v  )   (u  , v  )
2 2 2 2 2 
TM

Periodic Noise Reduction


Bandreject filters, Bandpass filters, Notch filters, Optimum notch filters

Bandreject filters
* Reject an isotropic frequency

ideal Butterworth Gaussian

PSD2B- Digital Image Processing 57


TM

noisy spectrum

filtered

bandreject
PSD2B- Digital Image Processing 58
TM

Image Segmentation

Image segmentation is the operation of partitioning an


image into a collection of connected sets of pixels.

1. into regions, which usually cover the


image

2. into linear structures, such as


- line segments
- curve segments

3. into 2D shapes, such as


- circles
- ellipses
- ribbons (long, symmetric regions)

PSD2B- Digital Image Processing 59


TM

Thresholding

In A: light objects in dark background

To extract the objects:

Select a T that separates the objects from the background


i.e. any (x,y) for which f(x,y)>T is an object point

PSD2B- Digital Image Processing 60


TM

Region Based Segmentation


1. Region Growing
Region growing techniques start with one pixel of a
potential region and try to grow it by adding adjacent
pixels till the pixels being compared are too disimilar.

2. Clustering

•There are K clusters C1,…, CK with means m1,…, mK.


• The least-squares error is defined as
• Out of all possible partitions into K clusters,
choose the one that minimizes D.

3. Split and Merge

PSD2B- Digital Image Processing 61


TM

Syllabus- Unit 5

• Image compression Fundamentals


• Models
• Information theory
• Error free compression
• Lossy compression
• Predictive and transform coding
• JPEG standard.

PSD2B- Digital Image Processing 62


TM

Image Compression
• The goal of image compression is to reduce the amount of data
required to represent a digital image.

Data compression aims to reduce the amount of data while


preserving as much information as possible.

PSD2B- Digital Image Processing 63


TM

Types of Image Compression


• Lossless
– Information preserving
– Low compression ratios

• Lossy
– Not information preserving
– High compression ratios
Trade-off: information loss vs compression ratio

PSD2B- Digital Image Processing 64


TM

compression

Compression ratio:

PSD2B- Digital Image Processing 65


TM

Compression Ratio

Example:

PSD2B- Digital Image Processing 66


TM

Types of Redundancy

(1) Coding Redundancy


(2) Interpixel Redundancy
(3) Psychovisual Redundancy

• Data compression attempts to reduce one


or more of these redundancy types.

PSD2B- Digital Image Processing 67


TM

Coding Definitions

• Code: a list of symbols (letters, numbers, bits


etc.)
• Code word: a sequence of symbols used to
represent some information (e.g., gray levels).
• Code word length: number of symbols in a code
word.

PSD2B- Digital Image Processing 68


TM

Coding Redundancy
• Case 1: l(rk) = constant length

Example:

PSD2B- Digital Image Processing 69


TM

Interpixel redundancy
• Interpixel redundancy implies that pixel values are
correlated (i.e., a pixel value can be reasonably predicted
by its neighbors).


f ( x) o g ( x)   f ( x) g ( x  a)da


auto-correlation: f(x)=g(x)
PSD2B- Digital Image Processing 70
TM

Psycho visual redundancy


• The human eye is more sensitive to the lower
frequencies than to the higher frequencies in
the visual spectrum.
• Idea: discard data that is perceptually
insignificant!

PSD2B- Digital Image Processing 71


TM

Image Compression Model

PSD2B- Digital Image Processing 72


TM

Lossy Compression
• Transform the image into some other domain
to reduce interpixel redundancy.
~ (N/n)2 subimages

PSD2B- Digital Image Processing 73


TM

JPEG Compression

Entropy
encoder

Accepted as
an
international
image
compression
standard in
1992.

PSD2B- Digital Image Processing 74


TM

JPEG - Steps
1. Divide image into 8x8 subimages.
For each subimage do:
2. Shift the gray-levels in the range [-128, 127]
3. Apply DCT  64 coefficients
1 DC coefficient: F(0,0)
63 AC coefficients: F(u,v)

PSD2B- Digital Image Processing 75

Você também pode gostar