Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 18

Assignment no.

2
DIGITAL IMAGE PROCESSING
Topic Covered :
1. Sampling & Quantization
2. Neighbouring of Pixels
3. Spatial Filtering
4. Introduction to Fourier Transformation

Submitted To:
Mr. Vijay Dheer
A.P(CSE/IT Deptt.)

Submitted by:
Gurjeet Singh
M. Tech. (3rd Semester)
Roll No. -100686582255

Image Sampling & Quantization


* Basic Concepts - To create a digital image, we need to convert continuous sensed data into
digital form. This involves two processes: sampling and quantization. The Figure shows a
continuous image, f (x, y), that we want to convert to digital form. To convert it to digital form,
we have to sample the function in both coordinates and in amplitude. An image may be
continuous with respect to the x- and y- coordinates and also in amplitude. Idea behind sampling
and quantization is illustrated in Fig. 1. Digitizing the coordinate values is called sampling.
Digitizing the amplitude values is called quantization.

Fig. 1. Generating a digital image (a) Continuous image. (b) A scan line from A to B in the
continuous image. (c) Sampling & quantization. (d) Digital scan line.

The one- dimensional function shown in Fig. 1(b) is a plot of amplitude (gray level)
values of the continuous image along the line segment AB in Fig. 1(a).
To sample this function, we take equally spaced samples along line AB, as shown in
Fig.1(c). Location of each sample is given by a vertical tick mark in the bottom part of
the figure. The samples are shown as small white squares superimposed on the function.
The set of these discrete locations gives the sampled function. However, the values of the
samples still span (vertically) a continuous range of gray- level values. In order to form a
digital function, the gray- level values also must be converted (quantized) into discrete
quantities. The right side of Fig.1(c) shows the gray- level scale divided into eight
discrete levels, ranging from black to white. The vertical tick marks indicate the specific
value assigned to each of eight gray levels. The continuous gray levels are quantized
simply by assigning one of the eight discrete gray levels to each sample. The assignment
is made depending on the vertical proximity of a sample to a vertical tick mark. The
digital samples resulting from both sampling and quantization are shown in Fig. 1(d) and
Fig .2 (b).

Fig.
2 (a): Continuous image projected onto a sensor array.
2 (b): Result of image sampling and quantization.

Representing Digital Images


The result of sampling and quantizations is a matrix of real numbers as shown in Fig. 3,
Fig. 4 and Fig .5. The values of the coordinates at the origin are (x, y) = (0, 0). The next
coordinate values along the first row are (x, y) = (0, 1). The notation (0, 1) is used to
signify the 2nd sample along the 1st row.

Fig. 3: Coordinate convention used to represent digital images

Fig. 4: A digital image of size M x N


It is advantageous to use a more traditional matrix notation to denote a digital image and its
elements.

Fig. 5: A digital image


The number of bits required to store a digitized image is
b=MxNxk
Where M & N are the number of rows and columns, respectively. The number of gray levels is
an integer power of 2:
L = 2k where k =1, 2,24
It is common practice to refer to the image as a k-bit image. The spatial resolution of an image
is the physical size of a pixel in that image; i.e., the area in the scene that is represented by
a single pixel in that image. Dense sampling will produce a high resolution image in
which there are many pixels, each of which represents of a small part of the scene. Coarse

sampling will produce a low resolution image in which there are a few pixels, each of which
represents of a relatively large part of the scene.

Neighbouring of pixel
Neighbors of a Pixel are 4-neighbors, diagonal-neighbors, 8-neighbors.
A pixel p at coordinates (x, y) has four horizontal and vertical neighbors whose
coordinates are given by:
(x+1, y), (x-1, y), (x, y+1), (x, y-1) .
This set of pixels, called the 4-neighbors of p, is denoted by N4 (p). Each pixel is a
unit distance from (x, y), and some of the neighbors of p lie outside the digital
image if (x, y) is on the border of the image.
The four diagonal neighbors of p have coordinates:
(x+1, y+1), (x+1, y-1), (x-1, y+1), (x-1, y-1) and are denoted by ND(p). These
points, together with the 4-neighbors, are called the 8-neighbors of p, denoted by
N8(p). As before, some of the points in ND(p) and N8(p) fall outside the image if (x,
y) is on the border of the image.

Neighbourhood Operations
Neighbourhood operations simply operate on a larger neighbourhood of pixels than point
operations. Neighbourhoods are mostly a rectangle around a central pixel. Any size rectangle
and any shape filter are possible.

Fig: Simple Neighbourhood Operations


Some simple neighbourhood operations include:
Min: Set the pixel value to the minimum in the neighbourhood
Max: Set the pixel value to the maximum in the neighbourhood
Median: The median value of a set of numbers is the midpoint value in that set (e.g. from the set
[1, 7, 15, 18, 24] 15 is the median). Sometimes the median works better than the average.

Simple Neighbourhood Operations Example:

The Spatial Filtering Process

Spatial Filtering: Equation Form

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.
Smoothing Spatial Filters
One of the simplest spatial filtering operations we can perform is a smoothing operation. It is
Simply average all of the pixels in a neighbourhood around a central value. It is especially useful
in removing noise from images. It is also useful for highlighting gross detail.

/9

/9

/9

/9

/9

/9
/9

/9
/9

Fig: Simple averaging filter

Smoothing Spatial Filtering

Weighted Smoothing Filters


More effective smoothing filters can be generated by allowing different pixels in the
neighbourhood different weights in the averaging function. Pixels closer to the central pixel are
more important. It is often referred to as a weighted averaging.

1/16

2/16

1/16

2/16

4/16

2/16

1/16

2/16

1/16

Weighted averaging filter

Another Smoothing Example

By smoothing the original image we get rid of lots of the finer detail which
leaves only the gross features for Thresholding.

Averaging Filter Vs. Median Filter Example

Filtering is often used to remove noise from images. Sometimes a median filter works better than
an averaging filter.

There are a few approaches to dealing with missing edge pixels:


1. Omit missing pixels: It Only works with some filters. It can add extra code and
slow down processing.
2. Pad the image : It is typically with either all white or all black pixels.
3. Replicate border pixels.
4. Truncate the image.
5. Allow pixels wrap around the image : It can cause some strange image artefacts.

Introduction to Fourier Transformation


BASIS FUNCTIONS:
The Fourier Transform ( in this case, the 2D Fourier Transform ) is the series expansion of an
image function ( over the 2D space domain ) in terms of "cosine" image (orthonormal) basis
functions.
The definitons of the transform (to expansion coefficients) and the inverse transform are given
below:
F(u, v) = SUM{ f(x, y)*exp(-j*2*pi*(u*x+v*y)/N) }
f(x, y) = SUM{ F(u, v)*exp(+j*2*pi*(u*x+v*y)/N) }

and

where u = 0,1,2,...,N-1 and v = 0,1,2,...,N-1


x = 0,1,2,...,N-1 and y = 0,1,2,...,N-1
j = SQRT( -1 ) and SUM means double summation over proper x, y or u, v ranges.

MAGNITUDE VS. PHASE:


Recall that the definition of the Fourier Transform is:
F(u, v) = SUM{ f(x, y)*exp(-j*2*pi*(u*x+v*y)/N) }
f(x, y) = SUM{ F(u, v)*exp(+j*2*pi*(u*x+v*y)/N) }

and

where u = 0,1,2,...,N-1 and v = 0,1,2,...,N-1


x = 0,1,2,...,N-1 and y = 0,1,2,...,N-1
and SUM means double summation over proper x, y or u, v ranges.
Note that f(x, y) is the image and is REAL, but F(u, v) (abbreviate as F) is the FT and is, in
general, COMPLEX. Generally, F is represented by its MAGNITUDE and PHASE rather that its
REAL and IMAGINARY parts, where:
MAGNITUDE(F) = SQRT( REAL(F)^2+IMAGINARY(F)^2 )
PHASE(F) = ATAN( IMAGINARY(F)/REAL(F) )
Briefly, the MAGNITUDE tells "how much" of a certain frequency component is present and the
PHASE tells "where" the frequency component is in the image.
FFT stands for "Fast" Fourier Transform and is simply a fast algorithm for computing the
Fourier Transform.
Fourier Transformations:
Definition: The Fourier transform is a representation of an image as a sum of complex
exponentials of varying magnitudes, frequencies, and phases. The Fourier transform plays a
critical role in a broad range of image processing applications, including enhancement, analysis,
restoration, and compression.
If f(m, n) is a function of two discrete spatial variables m and n, then the two-dimensional
Fourier transform of f(m, n) is defined by the relationship. The variables 1 and 2 are frequency
variables; their units are radians per sample. F(1,2) is often called the frequencydomain representation off(m, n). F(1,2) is a complex-valued function that is periodic both
in 1 and 2, with period .

The inverse of a transform is an operation that when performed on a transformed image produces
the original image. The inverse two-dimensional Fourier transform is given by

Visualizing the Fourier Transform


To illustrate, consider a function f(m, n) that equals 1 within a rectangular region and 0
everywhere else. To simplify the diagram, f(m, n) is shown as a continuous function, even though
the variables m and n are discrete.
Rectangular Function

Discrete Fourier Transform


A discrete transform is a transform whose input and output values are discrete samples, making it
convenient for computer manipulation. There are two principal reasons for using this form of the
transform:
1. The input and output of the DFT are both discrete, which makes it convenient for computer
manipulations.
2. There is a fast algorithm for computing the DFT known as the fast Fourier transform (FFT).

The two-dimensional M-by-N DFT and inverse M-by-N DFT relationships are given by

Relationship to the Fourier Transform


The DFT coefficients F(p, q) are samples of the Fourier transform F(1,2).

You might also like