Sie sind auf Seite 1von 170

Digital Image Processing - 1

Dr. Chandran Saravanan


Assistant Professor, Dept. of C.S.E.,
NIT Durgapur
dr.cs1973@gmail.com
+91-94347-88036

Dr. Chandran Saravanan, NIT Durgapur, India


Digital Image Processing (DIP)
DIP is the use of computer algorithms to perform
image processing on digital images. --WIKI

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Digital
Any data fed into the computer is digital in the form of 0s and 1s
(binary form - voltage or magnetic polarization)

The data may be represented using 8 bit / 16 bit / 32 bit / 64 bit

Dr. Chandran Saravanan, NIT Durgapur, India


Image Processing
Representation of a scene in a paper / stone / cloth / etc. is picture or
image

In general image is assumed as in digital form

Performing a task using various steps is a processing

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Structure of the Human Eye
The retina is covered with
light receptors called
cones (6-7 million) and
rods (75-150 million)
Cones are concentrated
around the fovea and are
very sensitive to colour
Rods are more spread
out and are sensitive to
low levels of illumination

Dr. Chandran Saravanan, NIT Durgapur, India


Image Formation in the Eye
Muscles within the eye can be used to change the
shape of the lens allowing us focus on objects that are
near or far away
An image is focused onto the retina causing rods and
cones to become excited which ultimately send signals
to the brain

Dr. Chandran Saravanan, NIT


Durgapur, India
Dr. Chandran Saravanan, NIT Durgapur, India
Brightness Adaptation & Discrimination
The human visual system can perceive approximately
1010 different light intensity levels
However, at any one time we can only discriminate
between a much smaller number brightness
adaptation
Similarly, the perceived intensity of a region is related
to the light intensities of the regions surrounding it

Dr. Chandran Saravanan, NIT Durgapur, India


Brightness Adaptation & Discrimination
(cont)

An example of Mach bands


Dr. Chandran Saravanan, NIT
Durgapur, India
Optical Illusions
Our visual systems
play lots of
interesting tricks on
us

Dr. Chandran Saravanan, NIT


Durgapur, India
Optical Illusions (continues )

Dr. Chandran Saravanan, NIT


Durgapur, India
Light And The Electromagnetic Spectrum

Light is just a particular part of the electromagnetic


spectrum that can be sensed by the human eye
The electromagnetic spectrum is split up according to
the wavelengths of different forms of energy

Dr. Chandran Saravanan, NIT


Durgapur, India
Image Representation
Before we discuss image acquisition recall that a digital
image is composed of M rows and N columns of pixels
each storing a value
Pixel values are most
col
often grey levels in the
range 0-255(black-white)
We will see later on
that images can easily
be represented as
matrices

f (row, col)
row
Dr. Chandran Saravanan, NIT Durgapur, India
Image Acquisition
Images are typically generated by illuminating a scene
and absorbing the energy reflected by the objects in
that scene

Typical notions of
illumination and scene
can be way off:
X-rays of a skeleton
Ultrasound of an
unborn baby
Electro-microscopic images of
molecules

Dr. Chandran Saravanan, NIT


Durgapur, India
Image Sensing
Incoming energy lands on a sensor material
responsive to that type of energy and this generates a
voltage
Collections of sensors are arranged to capture images

Imaging Sensor

Line of Image Sensors


Array of Image Sensors
Dr. Chandran Saravanan, NIT Durgapur, India
Image Sensing

Dr. Chandran Saravanan, NIT


Durgapur, India Using Sensor Strips and Rings
Image Sampling
A digital sensor can only measure a limited number of
samples at a discrete set of energy levels
Quantisation is the process of converting a continuous
analogue signal into a digital representation of this
signal

Dr. Chandran Saravanan, NIT Durgapur, India


Image Sampling (continues )
Remember that a digital image is always only an
approximation of a real world scene

Dr. Chandran Saravanan, NIT Durgapur, India


Image Resolution
Image resolution is described in PPI, number of pixels per inch of an
image.
Higher resolutions - more pixels per inch (PPI), resulting a high-
quality, crisp image.
Images with lower resolutions have fewer pixels, and if those few
pixels are too large (usually when an image is stretched), they
become .

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Dr. Chandran Saravanan, NIT Durgapur, India
Spatial Resolution
The spatial resolution of an image is determined by
how sampling was carried out
Spatial resolution simply refers to the smallest
discernable detail in an image
Vision specialists will
often talk about pixel
size
Graphic designers will
talk about dots per
inch (DPI)

Dr. Chandran Saravanan, NIT Durgapur, India


Spatial Resolution (continues )

Dr. Chandran Saravanan, NIT Durgapur, India


Megapixel ?
A megapixel (that is, a million pixels) is a unit of image sensing
capacity in a digital camera.
the more megapixels in a camera, the better the resolution when
printing an image in a given size.
a 1.3 megapixel resolution will print a good quality 4 x 3 inch print at
300 dpi

Dr. Chandran Saravanan, NIT Durgapur, India


Max Print Size Minimum MP Resolution

4 x 6 2 megapixels 1600 x 1200

5 x 7 3 megapixels 2048 x 1536

8 x1 0 5 megapixels 2560 x 1920

11 x 14 6 megapixels 2816 x 2112

16 x 20 8 megapixels 3264 x 2468

16 x 24 12 megapixels 42002800

Dr. Chandran Saravanan, NIT Durgapur, India


Intensity Level Resolution
Intensity level resolution refers to the number of intensity levels
used to represent the image

The more intensity levels used, the finer the level of detail
discernable in an image
Intensity level resolution is usually given in terms of the
number of bits used to store each intensity level

Number of Intensity
Number of Bits Examples
Levels
1 2 0, 1
2 4 00, 01, 10, 11
4 16 0000, 0101, 1111
8 256 00110011, 01010101
16 65,536 1010101010101010

Dr. Chandran Saravanan, NIT Durgapur, India


Resolution (continues )
256 grey levels (8 bits per pixel) 128 grey levels (7 bpp) 64 grey levels (6 bpp) 32 grey levels (5 bpp)

16 grey levels (4 bpp) 8 grey levels (3 bpp) 4 grey levels (2 bpp) 2 grey levels (1 bpp)

Dr. Chandran Saravanan, NIT Durgapur, India


Resolution: How Much Is Enough?
The big question with resolution is always how much is
enough?
This all depends on what is in the image and what you
would like to do with it
Key questions include
Does the image look aesthetically pleasing?
Can you see what you need to see within the image?

Dr. Chandran Saravanan, NIT Durgapur, India


How Much Is Enough? (continues )

The picture on the right is fine for counting the


number of cars, but not for reading the number plate

Dr. Chandran Saravanan, NIT Durgapur, India


Resolution (continues )

Low Detail Medium Detail High Detail

Dr. Chandran Saravanan, NIT Durgapur, India


Fundamental Steps in DIP
Image Acquisition acquiring image in digital form
Image Enhancement - manipulation of image for
specific application
Image Restoration - improving appearance of an image
- mathematical models
Color image processing - classification
Wavelets - representing images in various degrees
Compression - for reducing the storage size of an image

Dr. Chandran Saravanan, NIT


Durgapur, India
Fundamental Steps in DIP cont
Morphological processing - tools for extrating image
components
Segmentation - partition image into various objects
Representation - representing data suitable for
computer
Recognition - assigning a label to an object

Dr. Chandran Saravanan, NIT


Durgapur, India
Components of DIP
Image Sensor and Digitizer
Specialised image processing Hardware - ALU
Software - specialised modules for DIP
Computer - custom configuration
Mass storage - depeds on the application
Image displays - monitor
Hardcopy devices - printer
Network
Pixels and Values
Relationship between pixels
Neighbours of a pixel
four horizontal and vertical neighbours
(x+1,y)
(x-1,y)
(x,y+1)
(x,y-1)
4-neighbors of p is denoted by N4(p)
Relationship between pixels cont
Four diagonal neighbours of p
(x+1,y+1)
(x+1,y-1)
(x-1,y+1)
(x-1,y-1)

ND(p)

8 neighbours N8(p)
Adjacency
V is set of intensity values

4-adjacency - two pixels p and q with values from,V are 4-


adjacent if q is in the set N4(p)

8-adjacency - two pixels p and q with values from,V are 8-


adjacent if q is in the set N8(p)

m-adjacency - two pixels p and q with values from,V are


m-adjacent if q is in the set N4(p) or ND(p)
Path and Closed Path
A digital path from pixel p (x,y) to pixel q(s,t) is a
sequence of distinct pixels
(x0,y0),(x1,y1),...,(xn,yn)
where (x0,y0)=(x,y), (xn,yn),=(s,t)
and pixels (xi,yi) and (xi-1,yi-1) are adjacent for 1 <= I <=n

n is length of the path


(x0,y0)=(xn,yn) is closed path
Path
S is subset of pixels in an image
two pixels p and q are connected if a path exists
between them consisting of pixels in S
For any pixel p in S the set of pixels that are connected
to it in S is connected component of S, if it has only one
connected component is called connected set
Foreground and Background
An Image contains K disjoint regions,
Rk, k=1,2,,k none of which touches image border
Ru denotes the union of all the k regions
RuC denotes its complement
Ru the foreground of the image
RuC the background of the image

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Boundary
Boundary or Border or Contour of a Region R that are adjacent to
points in the complement of R.
The border of a region is the set of pixels in the region that have
atleast one background neighbor.
8-connectivity is used to define adjacency between points and
background

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Distance Measures
For pixels p, q, z with coordinates (x,y), (s,t), (v,w) respectively
D is a distance function or metric
(a) D(p,q) >= 0 (D(p,q)=0, iff p=q)
(b) D(p,q) = D(q,p) and
(c) D(p,z) <= D(p,q) + D(q,z)
Euclidean distance between p, q is
De(p,q)=[(x-s)2+(y-t)2]

Dr. Chandran Saravanan, NIT Durgapur, India


City Block Distance
D4 distance (CBD) between p and q is

D4(p,q)=|x-s|+|y-t|

D8 distance (chessboard distance) between p and q is

D8(p,q)=max(|x-s|,|y-t|)

Dr. Chandran Saravanan, NIT Durgapur, India


Contours of Constant Distance
D4 distance contour <=2 from (x, y)
2
212
21012
212
2
D4=1 are the 4 neighbours of (x, y)

Dr. Chandran Saravanan, NIT Durgapur, India


Contours of Constant Distance
D8 distance contour <=2 from (x, y)
22222
21112
21012
21112
22222
D8=1 are the 8 neighbours of (x, y)

Dr. Chandran Saravanan, NIT Durgapur, India


Other operations
Array, Matrix operations
Linear, Nonlinear operations
Arithmetic operations
Set and Logical operations fuzzy sets
Spatial operations
Geometric spatial transformations Identity, Scaling, Rotation, Translation, Shear
(Vertical and Horizontal)
Vector and Matrix Operations
Image Transforms
Probalistic Methods

Dr. Chandran Saravanan, NIT Durgapur, India


Translation x = u + t, u = x - t
Scaling x = s * u, x / s
Rotation x = u cos - v sin

Dr. Chandran Saravanan, NIT Durgapur, India


Questions
Entering a dark theatre from a bright outer side, it takes few seconds
to adjust to the darker theatre for finding the objects inside such as
pathway, seats, people, etc. What could be the reason ?
Blue, green, red, and white colour cars and respective colour spare
parts should be picked using robot. Suggest a cost effective solution.

Dr. Chandran Saravanan, NIT Durgapur, India


Questions
How many minutes would it take to transmit a 2048 x 2048 image
with 256 intensity levels using 33.6k baud modem?
A CCD camera chip of dimensions 14 x 14 mm having 2048 x 2048
elements focused on a square area, located 0.5m away. How many
line pairs per mm will this camera be able to resolve?

Dr. Chandran Saravanan, NIT Durgapur, India


Applications
1 Selection 12 Enhancing images
2 Layers 13 Sharpening and softening images
3 Image size alteration 14 Selecting and merging of images
4 Cropping an image 15 Slicing of images
5 Histogram 16 Special effects
6 Noise reduction 17 Stamp Clone Tool
7 Removal of unwanted elements 18 Change color depth
8 Selective color change 19 Contrast change and brightening
9 Image orientation 20 Gamma correction
10 Perspective control & distortion 21 Color adjustments
11 Lens correction 22 Printing / Warping

Dr. Chandran Saravanan, NIT Durgapur, India


Linear and non-linear operations
Most important classifications of an image
Linear
Non-linear
Operator H produces an output image g(x,y) for input image f(x,y)
H [f(x,y) ] = g(x,y)

Dr. Chandran Saravanan, NIT Durgapur, India


Linear and non-linear operations
H is a linear operator, if
H [ai fi (x,y) + aj fj (x,y)] = ai H [ fi (x,y)] + aj H [fj (x,y)]
=ai gi (x,y) + aj gj (x,y)
Where, ai, aj, fi(x,y), and fj(x,y) are arbitrary constants and images of
the same size respectively

Dr. Chandran Saravanan, NIT Durgapur, India


Linear and non-linear operations
Linear operations properties are additivity and homogeneity
Sum of two inputs is same as performing linear operation and sum
(additivity)
Linear operation at constant times is same as original input multiplied
by constant then linear operation

Dr. Chandran Saravanan, NIT Durgapur, India


Linear and non-linear operations

Dr. Chandran Saravanan, NIT Durgapur, India


Linear and non-linear operations

Dr. Chandran Saravanan, NIT Durgapur, India


Arithmetic Operations
Arithmetic operations are Array operations,
the basic four arithmetic operations are
s(x,y) = f(x,y) + g(x,y)
d(x,y) = f(x,y) - g(x,y)
p(x,y) = f(x,y) * g(x,y)
v(x,y) = f(x,y) / g(x,y)
Operations are performed between corresponding pixel pairs in f and
g for x=0,1,2,,m-1 and y=0,1,2,,n-1
Example, addition (+) of noise, reduction (-) of noise, shading
correction (* and /), masking ROI operations (*)
Logical operations
A be a set composed of ordered pairs of real numbers
If a=(a1,a2) is an element of A then
If a is not element of A then
Set with no elements is null or empty set
If every element of a set A is also an element of a set B, then A is subset of
B denoted as
The union of two sets A and B denoted by
Intersection of two sets A and B denoted by
Two sets A and B have no common elements denoted as disjoint or
mutually exclusive =
Spatial Filtering
Spatial domain refers the image plane direct manipulations of pixels
in an image
Two principal categories are intensity transformations and spatial
filtering
intensity transformations for the purpose of contrast manipulation
and image thresholding
spatial filtering deals with such as image sharpening, smoothing

Dr. Chandran Saravanan, NIT Durgapur, India


Background
Spatial domain techniques are more efficient computationally and
require less processing resources to implement
g(x,y)=T[f(x,y)]
where f(x,y) is the input image, g(x,y) is the output image and T is an
operator on f defined over a neighborhood of point (x,y)
The operator can apply to a single image or set of images

Dr. Chandran Saravanan, NIT Durgapur, India


Intensity Transformation Functions
Simplest of all image processing functions
Values of pixels before and after processing are denoted by r and s
resp.
s=T(r)
T is a transformation, maps r into s
Mappings are implemented via table lookups (8 bit 256 values)

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Image Enhancement
3 types of functions used for image enhancement
Linear (negative and identity transformations)
Logarithmic (log and inverse-log transformations)
Power-law (nth power and nth root transformations)

Dr. Chandran Saravanan, NIT Durgapur, India


Image Negatives
Negative transformation is denoted as
s=L-1-r
where intensity level range is [0,L-1]
Reversing the intensity levels produces photography negative
Suited for enhancing white or gray details embedded in dark regions
of an image

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Original and Negative Mammogram

Dr. Chandran Saravanan, NIT Durgapur, India


Log Transformations
General form of log transformation denoted as s= c * log(1+r)
Where c is a constant and assumed that r >=0
Maps a narrow range of low intensity input values into a wider ranger
of output levels
Used to expand dark pixels in an image while compressing the higher
level values

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Power-Law (Gamma) Transformations

Dr. Chandran Saravanan, NIT Durgapur, India


Plots of the equation s

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Contrast Stretching
Low contrast images can result from
poor illumination,
lack of dynamic range in the imaging sensor,
wrong setting of a lens aperture during image acquisition
contrast stretching expands the range of intensity levels so that it
spans the full intensity levels of recording or display device

Dr. Chandran Saravanan, NIT Durgapur, India


Form of Transformation Function, Low contrast image, result of contrast stretching,
result of thresholding

Dr. Chandran Saravanan, NIT Durgapur, India


Intensity Level Slicing
Highlighting a specific range of intensities
Enhancing features masses of water in satellite imagery flaws in x-
ray images
Two basic themes First one, to display in white and all the range
values in black
Second one, transformation brightens / darkens the desired range of
pixel values
Applications highlight major blood vessels that appear brighter than
the background

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Histogram
Histogram is a graphical representation of the distribution of
numerical data in bar graph, first introduced by Karl Pearson.
Probability distribution of a continuous variable
To construct a histogram, divide the entire range of values into a
series of intervals
Then count how many values fall into each interval
Plot the graph pixel value vs. frequency

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Etymology
The etymology of the word histogram is uncertain.
Sometimes it is said to be derived from the Ancient Greek
histos and gramma "drawing, record, writing anything set upright"

Dr. Chandran Saravanan, NIT Durgapur, India


Mathematicaly
A histogram is a function mi that counts the number of observations
that fall into each of the disjoint categories (known as bins), whereas
the graph of a histogram is merely one way to represent a histogram.
Let n be the total number of observations and k be the total number
of bins, the histogram mi meets the following conditions:

Dr. Chandran Saravanan, NIT Durgapur, India


Histogram
The histogram graphically shows the following:
center (i.e., the location) of the data;
spread (i.e., the scale) of the data;
skewness of the data;
presence of outliers; and
presence of multiple modes in the data.

Dr. Chandran Saravanan, NIT Durgapur, India


Normal

The classical bell-shaped, symmetric histogram with most of the frequency counts bunched in the middle
and with the counts dying off out in the tails. From a physical science / engineering point of view, the
normal distribution is that distribution which occurs most often in nature.

Dr. Chandran Saravanan, NIT Durgapur, India


Symmetric, Non-Normal, Short-Tailed

Dr. Chandran Saravanan, NIT Durgapur, India


Symmetric, Non-Normal, Long-Tailed

Dr. Chandran Saravanan, NIT Durgapur, India


Symmetric and Bimodal

Dr. Chandran Saravanan, NIT Durgapur, India


Bimodal Mixture of 2 Normals

Dr. Chandran Saravanan, NIT Durgapur, India


Skewed (Non-Normal) Right

Dr. Chandran Saravanan, NIT Durgapur, India


Skewed (Non-Symmetric) Left

Dr. Chandran Saravanan, NIT Durgapur, India


Symmetric with Outlier

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Skewed. The skewed distribution is asymmetrical because a natural limit prevents
outcomes on one side. The distributions peak is off center toward the limit and a
tail stretches away from it.
For example, a distribution of analyses of a very pure product would be skewed,
because the product cannot be more than 100 percent pure. Other examples of
natural limits are holes that cannot be smaller than the diameter of the drill bit or
call-handling times that cannot be less than zero. These distributions are called
right or leftskewed according to the direction of the tail.

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Double-peaked or bimodal. The bimodal distribution looks like the
back of a two-humped camel. The outcomes of two processes with
different distributions are combined in one set of data. For example, a
distribution of production data from a two-shift operation might be
bimodal, if each shift produces a different distribution of results.
Stratification often reveals this problem.

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Plateau. The plateau might be called a multimodal distribution.
Several processes with normal distributions are combined. Because
there are many peaks close together, the top of the distribution
resembles a plateau.
Edge peak. The edge peak distribution looks like the normal
distribution except that it has a large peak at one tail. Usually this is
caused by faulty construction of the histogram, with data lumped
together into a group labeled greater than

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Comb. In a comb distribution, the bars are alternately tall and short.
This distribution often results from rounded-off data and/or an
incorrectly constructed histogram. For example, temperature data
rounded off to the nearest 0.2 degree would show a comb shape if
the bar width for the histogram were 0.1 degree.

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Truncated or heart-cut. The truncated distribution looks like a normal
distribution with the tails cut off. The supplier might be producing a
normal distribution of material and then relying on inspection to
separate what is within specification limits from what is out of spec.
The resulting shipments to the customer from inside the
specifications are the heart cut.

Dr. Chandran Saravanan, NIT Durgapur, India


Histograms
Dog food The dog food distribution is missing somethingresults near the
average. If a customer receives this kind of distribution, someone else is receiving
a heart cut, and the customer is left with the dog food, the odds and ends left
over after the masters meal. Even though what the customer receives is within
specifications, the product falls into two clusters: one near the upper
specification limit and one near the lower specification limit. This variation often
causes problems in the customers process.

Dr. Chandran Saravanan, NIT Durgapur, India


Histogram Equalization
Histogram equalization is a technique for adjusting image intensities
to enhance contrast.
Let f be a given image represented as a m by n matrix of integer pixel
intensities ranging from 0 to L 1.
L is the number of possible intensity values, often 256.
Let p denote the normalized histogram of f with a bin for each
possible intensity.

Dr. Chandran Saravanan, NIT Durgapur, India


HE Formula
Pn= number of pixels with intensity n i.e. total number of pixels,

n=0, 1, 2, ... L-1

Histogram Equalized image G = floor ((L-1) Summation of Pn from n=0


to F(i,j))

Dr. Chandran Saravanan, NIT Durgapur, India


Dr. Chandran Saravanan, NIT Durgapur, India
Dr. Chandran Saravanan, NIT Durgapur, India
Dr. Chandran Saravanan, NIT Durgapur, India
Correlation and Convolution
Correlation and Convolution are basic operations that we will perform
to extract information from images.
They are shift-invariant, and they are linear.
Shift-invariant means same operation performed at every point in
the image.
Linear means that we replace every pixel with a linear combination of
its neighbors.

Dr. Chandran Saravanan, NIT Durgapur, India


Correlation
Performed by Local Averaging

Image I = {5,4,2,3,7,4,6,5,3,6}

Fourth value 3 is replaced with average of 2, 3, 7 (neighbours)

J(4)=(I(3)+I(4)+I(5))/3=(2+3+7)/3=4

Dr. Chandran Saravanan, NIT Durgapur, India


2D correlation
834 88344 6.44 5.22 4
764 88344 5.77 5.33 4.88
457 77644 5.11 5.44 5.77
44577
44577

Dr. Chandran Saravanan, NIT Durgapur, India


Convolution
Convolution is just like correlation, except that flip over the filter
before correlating.
For example, convolution of a 1D image with the filter (3,7,5) is
exactly the same as correlation with the filter (5,7,3).
In the case of 2D convolution flip the filter both horizontally and
vertically.

Dr. Chandran Saravanan, NIT Durgapur, India


Smoothing Filters
Additive smoothing / Laplace / Lidstone
Butterworth filter
Digital filter
Kalman filter
Kernel smoother
Laplacian smoothing
Stretched grid method
Low-pass filter
SavitzkyGolay smoothing filter based on the least-squares fitting of polynomials
Local regression also known as "loess" or "lowess"
Smoothing spline
RamerDouglasPeucker algorithm
Moving average
Exponential smoothing
KolmogorovZurbenko filter

Dr. Chandran Saravanan, NIT Durgapur, India


Filtering
Images are often corrupted by random variations in intensity,
illumination, or have poor contrast and cant be used directly
Filtering: transform pixel intensity values to reveal certain image
characteristics
Enhancement: improves contrast
Smoothing: remove noises
Template matching: detects known patterns

Dr. Chandran Saravanan, NIT Durgapur, India


Filtering continues

The operator can apply to a single image or set of images

1/9 x
1 1 1
1 1 1
1 1 1

1/16 x
1 2 1
2 4 2
1 2 1
Filtering continues
Smoothing filters are used for blurring and for noise reduction
Blurring is used in preprocessing tasks, removal of small details, bridging
small gaps in lines or curves
Noise reduction can be accomplished by blurring with a linear filter and
also by nonlinear filtering
Output of smoothing, linear spatial filter is average of pixels contained in
the neighborhood of the filter mask
Also called as averaging filters / lowpass filters
Averaging filters blur images due to averaging the edges
Averaging filter with all coefficients are called box filter
Averaging and Median Filter
Averaging and Median Filter

Original Image Averaging Filter Median Filter


Filtering continues
Second mask is called weighted average
the pixels are multiplied by different values / coefficients
giving importance to some pixels at the expense of others
the center pixel is multiplied with higher value
other pixels are inversely weighted
distance from the center of the mask
sum of all coefficients is 16 integer power of 2
region is very small 3 x 3
effect of smoothing depends on the size of the mask
size normally ranging from 3, 5, 9, 15, 35 pixels
Filtering continues
size 3 will produce slightly blurred image and 35 will produce more blurred image
3 and 5 somewhat similar
in 9, 20% black circle is not nearly as distinct from the background
35 is aggressive, used to eliminate small objects from an image
padding with 0s will form a black border
smaller objects blend with the background
larger objects will become blob like - easy to detect
Example Hubble telescope image may have smaller objects
smoothing process diminish the smaller objects threshold values are introduced to
control blurring effect
Hubble Telescope
Hubble Telescope Image
Hubble Telescope Image
Non-linear filters
order statistic filter based on ordering filters
best known is median filter
replaces the median value with the center of the pixel value
for random noise median filter provides better result
median filters are effective in impulsive noise / salt and pepper noise
white and black dots superimposed on image
Salt and Pepper noise
Non-linear filters continues
3 x 3 filter 5th value in the sorted list
5 x 5 filter 13th value in the sorted list
example (10, 20, 20, 20, 20, 15, 20, 20, 25, 100)
sorted values are (10, 15, 20, 20, 20, 20, 20, 20, 25, 100)
median value is 20 replaced with the center value
similarly we can have max filter and min filter max value is 100 and
min value is 10
max identifies highest intensity pixels / brightest pixels
min filter finds the opposite
Sharpening Filters
highlights transitions in intensity
applications are electronic printing, medical imaging, autonomous
guidance, etc.
Smoothing or averaging is analogous to integration
sharpening is analogous to differentiation
first order and second order derivatives are used
must be zeros in areas of constant intensity
must be non zero in ramp or step intensity
Sharpening Filters continues
zero crossing property is useful for detecting edges
ramp like transitions reveals thick edges in first order derivative
second order derivative reveals double ridges separated by zeros
thus second order derivative enhances fine detail and better than first order
derivative
which is suitable for sharpening
second order derivative is easier to implement than first order derivative
A high-pass filter can be used to make an image appear sharper
If there is no change in intensity, nothing happens. But if one pixel is brighter than its
immediate neighbors, it gets boosted
Sharpening Filters continues

0 1 0 0 -1 0
1 -4 1 -1 4 -1
0 1 0 0 -1 0

1 1 1 -1 -1 -1
1 -8 1 -1 8 -1
1 1 1 -1 -1 -1

Dr. Chandran Saravanan, NIT Durgapur, India


Sharpening Filters continues
Sharpening Filters continues
The above 2D second order filters
isotropic filters rotation invariant
rotating the image and applying this filter will produce the same
result
independent of the direction of the discontinuities in the image
center is positive value then addition
center is negative then subtraction
Sharpening Filters continues
using Laplacian linear operator
f(x+1, y) + f(x-1, y) 2f(x,y)
f(x,y+1)+f(x, y-1)-2f(x,y)
f(x+1, y) + f(x-1, y) + f(x,y+1)+f(x, y-1)-4f(x,y)
the center value is 8 because, the two diagonals will add another 4,
that is horizontal 2, vertical 2, two diagonals each 2, 2+2+2+2=8
Unsharp Mask
highboost filtering - the technique uses a blurred, or "unsharp", negative image to create
a mask of the original image
The unsharped mask is then combined with the positive (original) image, creating an
image that is less blurry than the original.
An unsharp mask is simply another type of high-pass filter.
First, a mask is formed by low-pass filtering an image.
This mask is then subtracted from the original image.
This has the effect of sharpening the image.
similar to second order derivative
change of slope is emphasized

Dr. Chandran Saravanan, NIT Durgapur, India


Unsharp Mask continues
used in printing and publishing industry to sharpen images
by subtracting the unsharp image from the original image
the steps are
1) blur the original image,
2) subtract the blurred image from original image (resulting difference is
mask),
3) add the mask to the original
Frequency Domain
analyze a signal with respect to time, but here,
analyze a signal with respect to frequency
first transform the image to its frequency distribution
Amplitude is the fluctuation or displacement of a wave from its mean value.
With sound waves, it is the extent to which air particles are displaced, and
this amplitude of sound or sound amplitude is experienced as the loudness of
sound.
Introduction to Fourier
French mathematician Jean Baptise Joseph Fourier born 1768 in a town Auxerre
about midway Paris and Dijon
His major contribution was outlined in 1807 in a memoir and published in 1822 in
is book La Theorie Analitique de la Chaleur (The Analytic Theory of Heat). This
book was translated into English 55 years later by Freeman
Fourier states that any periodic function can be expressed as the sum of sines and
cosines of different frequencies each multiplied by a different coefficient
Fourier Series continues
In order to process an image in frequency domain, we need to first
convert it into frequency domain
we have to take inverse of the output to convert it back into spatial
domain.
Thats why both Fourier series and Fourier transform has two
formulas.
One for conversion and one converting it back to the spatial domain.
Fourier Series continues
The Fourier series can be denoted by this formula.

The inverse can be calculated by this formula.


Fourier transform
The Fourier transform simply states that that the non periodic signals
whose area under the curve is finite can also be represented into
integrals of the sines and cosines after being multiplied by a certain
weight.
The Fourier transform has many wide applications that include, image
compression (e.g JPEG compression), filtering and image analysis.
Difference between Fourier series and transform
Although both Fourier series and Fourier transform are given by Fourier, but the
difference between them is Fourier series is applied on periodic signals and
Fourier transform is applied for non periodic signals
Now the question is that which one is applied on the images, the Fourier series or
the Fourier transform. Well, the answer to this question lies in the fact that what
images are. Images are non periodic.
Since the images are non periodic, so Fourier transform is used to convert them
into frequency domain
Discrete Fourier Transform
Since we are dealing with images, and in fact digital images, so for
digital images we will be working on discrete fourier transform
Consider the above Fourier term of a sinusoid. It include three things.
Spatial Frequency
Magnitude
Phase
DFT continues
The spatial frequency directly relates with the brightness of the image
The magnitude of the sinusoid directly relates with the contrast
Contrast is the difference between maximum and minimum pixel
intensity
Phase contains the color information
DFT & IDFT
The formula for 2 dimensional discrete Fourier transform is given below.

The formula for 2 dimensional inverse discrete Fourier transform is given below.

The discrete Fourier transform is actually the sampled Fourier transform, so it contains
some samples that denotes an image.
In the above formula f(x,y) denotes the image, and F(u,v) denotes the discrete Fourier
transform.
Frequency Filters
Frequency filters process an image in the frequency domain.
The image is Fourier transformed, multiplied with the filter function and then re-
transformed into the spatial domain.
Attenuating high frequencies results in a smoother image in the spatial domain
Attenuating low frequencies enhances the edges
G(k,l)=F(k,l) x H(k,l)
Where, F is input image in Fourier domain,
H is the filter function and G is the filtered image
G will be applied IFT to get reproduced image
Frequency Filters continues
There are basically three different kinds of filters: lowpass,
highpass, and bandpass filters.
A low-pass filter attenuates high frequencies and retains low
frequencies unchanged.
The result in the spatial domain is equivalent to that of a smoothing
filter;
A highpass filter, on the other hand, yields edge enhancement or
edge detection in the spatial domain, because edges contain many
high frequencies
Frequency Filters continues
A bandpass attenuates very low and very high frequencies, but retains a middle range
band of frequencies. Bandpass filtering can be used to enhance edges (suppressing low
frequencies) while reducing the noise at the same time (attenuating high frequencies)
The drawback of low-pass filter function is a ringing effect that occurs along the edges of
the filtered spatial domain image.
Better results can be achieved with a Gaussian shaped filter function. The advantage is
that the Gaussian has the same shape in the spatial and Fourier domains
A commonly used discrete approximation to the Gaussian is the Butterworth filter.
Frequency Filters continues
One difference is that the computational cost of the spatial filter
increases with the standard deviation
whereas the costs for a frequency filter are independent of the filter
function
the spatial Gaussian filter is more appropriate for narrow lowpass
filters, while the Butterworth filter is a better implementation for
wide lowpass filters
Butterworth Low Pass Filters Example
Butterworth Lowpass Filters
1930 by the British engineer and physicist Stephen Butterworth
maximally flat magnitude filter
successively closer approximations were obtained with increasing
numbers of filter elements of the right values
basic Butterworth low-pass filter could be modified to give low-
pass, high-pass, band-pass and band-stop functionality.
Gaussian Filters
a Gaussian filter is a filter whose impulse response is a Gaussian function
Gaussian filters have the properties of having no overshoot to a step
function input while minimizing the rise and fall time
The focal element receives the heaviest weight (having the highest
Gaussian value) and neighboring elements receive smaller weights as their
distance to the focal element increases
Gaussian Filters Example
Homomorphic Filtering
is a generalized technique for signal and image processing, involving a
nonlinear mapping to a different domain in which linear filter techniques
are applied, followed by mapping back to the original domain.
This concept was developed in the 1960s by Thomas Stockham, Alan V.
Oppenheim, and Ronald W. Schafer at MIT.
Homomorphic filtering is most commonly used for correcting non-uniform
illumination in images.
Homomorphic Filtering cont
Homomorphic filter is used for image enhancement.
It simultaneously normalizes the brightness and increases contrast.
Homomorphic filtering is used to remove multiplicative noise.
Multiplicative noise refers to an unwanted random signal that gets multiplied into
some relevant signal during capture, transmission, or other processing.
Dark spots caused by dust in the lens or image sensor, and variations in the gain
of individual elements of the image sensor array
Homomorphic Filtering cont
Illumination and reflectance are not separable, but their approximate locations in
the frequency domain may be located.
Since illumination and reflectance combine multiplicatively, the components are
made additive by taking the logarithm of the image intensity, so that these
multiplicative components of the image can be separated linearly in the
frequency domain.
Illumination variations can be thought of as a multiplicative noise, and can be
reduced by filtering in the log domain.
Homomorphic Filtering cont
To make the illumination of an image more even, the high-frequency components
are increased and low-frequency components are decreased,
because the high-frequency components are assumed to represent mostly the
reflectance in the scene,
whereas the low-frequency components are assumed to represent mostly the
illumination in the scene.
That is, high-pass filtering is used to suppress low frequencies and amplify high
frequencies, in the log-intensity domain
Homomorphic Filtering cont
I(x,y)=L(x,y) R(x,y) - where I is the image, L is scene illumination, and R is
the scene reflectance
Illumination typically varies slowly across the image as compared to
reflectance which can change quite abruptly at object edges.
In homomorphic filtering we first transform the multiplicative components
to additive components by moving to the log domain.
ln(I(x,y))=ln(L(x,y) R(x,y))
ln(I(x,y))=ln(L(x,y))+ln(R(x,y))
Homomorphic Filtering cont
Then we use a high-pass filter in the log domain to remove the low-
frequency illumination component while preserving the high-
frequency reflectance component. The basic steps in homomorphic
filtering are shown in the diagram below:
In this image the background illumination changes gradually from the top-left corner to the bottom-
right corner of the image.
Let's use homomorphic filtering to correct this non-uniform illumination.
The first step is to convert the input image to the log domain.
The next step is to do Gaussian high-pass filtering. We high-pass filter the log-transformed image in the
frequency domain.
We compute the FFT of the log-transformed image with zero-padding
Then we apply the high-pass filter and compute the inverse-FFT.
We crop the image back to the original unpadded size.
The last step is to apply the exponential function to invert the log-transform and get the homomorphic
filtered image.
Fast Fourier Transform
The fast Fourier transform (FFT) is a discrete Fourier
transform algorithm which reduces the number of computations
from O(N2) to O(NlgN), where lg is the base-2 logarithm, can be 20-
30% faster
FFTs were first discussed by Cooley and Tukey (1965), although Gauss
had actually described the critical factorization step as early as 1805
(Bergland 1969, Strang 1993).
FFT continues
The first stage breaks the 16 point signal into two signals each consisting of 8 points.
The second stage decomposes the data into four signals of 4 points.
This pattern continues until there are N signals composed of a single point.
An interlaced decomposition is used each time a signal is broken in two, that is, the
signal is separated into its even and odd numbered samples.
The best way to understand this is by inspecting Fig. 12-2 until you grasp the pattern.
There are Log2N stages required in this decomposition, i.e., a 16 point signal (24) requires
4 stages, a 512 point signal (27) requires 7 stages, a 4096 point signal (212) requires 12
stages, etc.
FFT continues
On the left, the sample numbers of the original signal are listed along with
their binary equivalents.
On the right, the rearranged sample numbers are listed, also along with
their binary equivalents.
The important idea is that the binary numbers are the reversals of each
other.
For example, sample 3 (0011) is exchanged with sample number 12 (1100).
Likewise, sample number 14 (1110) is swapped with sample number 7
(0111), and so forth.

Das könnte Ihnen auch gefallen