Amity School of Engineering & Technology
Module I: Introduction and Digital Image Fundamentals The origins of Digital Image
Processing, Examples of Fields that Use Digital Image Processing, Fundamentals Steps in
Image Processing, Elements of Digital Image Processing Systems, Image Sampling and
Quantization, Some basic relationships like Neighbours, Connectivity, Distance Measures
between pixels, Linear and Non-Linear Operations.
- Shradha Dubey
Assistant Professor
Amity School of Engineering and Technology
Amity University, MP
Digital Image Processing Amity School of Engineering & Technology
• Image- Two Dimensional function – f(x,y)
where,
x,y – spatial coordinates
Amplitude of ‘f’ – Intensity or gray levels
• Digital Image - If x,y & amplitude of ‘f’ (intensity or gray level)
is finite and discrete
• Digital Image Processing - Processing digital image by means of
digital computer
• Pixels – Digital Images contains finite number of elements at
particular location and values
• 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
Amity School of Engineering & Technology
• Digital Image consist of M Rows and N Columns.
• Each pixel represented by k bits.
• A pixel therefore have 2k different values.
– .
– A bit (binary digit) can be either 0 or 1.
• If 1 bit is used, the pixel can have 2 values → (0, 1) (Black & White).
• If 2 bits are used, the pixel can have 4 values → (00, 01, 10, 11) (4 shades of gray).
• If k bits are used, the pixel can have 2k2k2k values
Resolution In pixel resolution, the term resolution refers to the total number of count of
pixels in a digital image. For example. If an image has M rows and N columns, then its
resolution can be defined as M X N.
Mathematically, it can be
represented as,
Aspect ratio- Aspect ratio is the ratio between width of an image and the height of an
image. It is commonly explained as two numbers separated by a colon (8:9).
Bit Depth- The number of bits necessary to encode the pixel value is called bit depth. Bit
depth is power of 2
Total number of bits necessary to represent image = No. of rows * No. of columns * Bit
Depth
Amity School of Engineering & Technology
Numericals
Q. If you are given an image with aspect ratio of 6:2 of an image of
pixel resolution of 480000 pixels given the image is a gray scale
image.
And you are asked to calculate two things.
(i) Resolve pixel resolution to calculate the dimensions of image.
(ii) Calculate the size of the image.
Q. What is the storage requirement for a 1024 x 1024 binary image ?
Amity School of Engineering & Technology
1. Given:
Aspect ratio: c:r = 6:2
Pixel resolution: c * r = 480000
Bits per pixel: grayscale image
= 8bpp
Find:
Number of rows = ? Solving 2nd part:
Size = rows * cols * bpp
Number of cols = ? Size of image in bits = 400 * 1200 * 8 =
3840000 bits
Size of image in bytes = 480000 bytes
Size of image in kilo bytes = 48 kb (approx).
Amity School of Engineering & Technology
Types of Image Processing
The continuum from image processing to computer vision can be broken up into low-, mid- and high-
level processes
Amity School of Engineering & Technology
Fundamental Steps in DIP
Amity School of Engineering & Technology
Components of DIP
1. Image Acquisition Equipment (Cameras,
Sensors etc.)
2. Storage (Short-term,Online, Offline)
3. Processing elements (CPU, GPU, Hardware,
Software)
4. Display Units (Computer, Monitor)
Amity School of Engineering & Technology
Sampling & Quantization
• To create a digital image, we need to convert continuous sensed
data into digital form.
• This conversion involves two process:
Sampling – Digitizing Coordinate Value
Quantization- Digitizing Amplitude value
Continuous Result of image
image projected after sampling
onto sensor and quantization
array
Zooming & Shrinking Amity School of Engineering & Technology
• Zooming - Zooming simply means enlarging a picture in a
sense that the details in the image became more visible and
clearer. Zooming an image has many wide applications
ranging from zooming through a camera lens, to zoom an
image on internet etc.
• Shrinking is opposite to zooming and reduces the pixels.
• Zooming & Shrinking are based on two Methods
(i) Nearest Neighbour Interpolation
(ii) Bilinear Interpolation
Amity School of Engineering & Technology
Relationship Between Pixels
• Let I is Image -> f(x,y)
where, s-> subset of pixels
p,q -> Particular pixel
Relationship can be represented as-
(i) 4- Neighbourhood pixel[N4(p)]: A pixel p at (x,y) has 4-
horizontal/vertical neighbours at (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
These are called the 4-neighbours of p : N4(p).
Coordinates of this is given by:
N4(p) = (x+1,y) (x-1,y) (x, y+1) (x, y-1)
(ii) Diagonal Neighbours [ND(p)]: A pixel p at (x,y) has 4 diagonal
neighbours at (x+1,y+1), (x+1,y-1), (x-1,y+1) and (x-1,y-1). These are
called the diagonal-neighbours of p : ND(p).
ND(p) = (x-1, y+1), (x+1, y+1), (x-1, y-1), (x+1, y-1)
(iii) 8- Neighbourhood pixel[N8(p)]: The 4-neighbours and the diagonal
neighbours of p are called 8-neighbours of p : N8(p).
N8(p) = N4(p) + ND(p)
Amity School of Engineering & Technology
Connectivity/ Adjacency
Two pixels are adjacent if they are neighbours and their intensity
level V satisfy some specific criteria of similarity.
Eg: Binary Image {0,1}
Gray Image {0,1,2, ……….255}
(i) 4- Adjacency:Two pixels p and q with values from V are 4-
adjacent if q is in the set N4(p).
(ii) 8- Adjacency: Two pixels p and q with values from V are 8-
adjacent if q is in the set N8(p).
(iii) m- Adjacency : Two pixels p and q with values from V are m-
adjacent if (if there exists both 4-way connections and 8-way connections then
consider 4-way connections first)
❖ q is in N4(p), or
❖ q is in ND(p) and the set N4(p)∩N4(q) has no pixels whose values are from
V.
Amity School of Engineering & Technology
Distance Measures between pixels
• Distance function D
p(x,y); z(u,v); q(s,t) are coordinates of particular pixel
Properties of D
(i) D(p,q) >= 0
(ii) D(p,q) = 0 if p=q
(iii)D(p,q) = D(q,p)
(iv)D(p,q) <= D(p,q) + D(q,z)
Amity School of Engineering & Technology
• Three types of distance measures are there
(i) Euclidean Distance - The Euclidean distance is the straight-line distance between two pixels.
DE (p,q) = [(x-s)2 + (y-t)2]^1/2
(ii) City Block - The city block distance metric measures the path between the pixels based on a 4-
connected neighborhood. Pixels whose edges touch are 1 unit apart; pixels diagonally touching are 2 units
apart.
D4(p,q) = |x-s| + |y-t|
(iii) Chess Board - The chessboard distance metric measures the path between the pixels based on an 8-
connected neighborhood. Pixels whose edges or corners touch are 1 unit apart.
D8(p,q) = max{|x-s|,|y-t|}
Amity School of Engineering & Technology
Q. An Image segment is shown below. Let V be the set of values used to define connectivity in the
image. Compute D4 ,D8, Dm between pixels ‘p’ and ‘q’ for
(i) V= [2,3]
(i) V = [2,6]
Solution:
2 (p) 3 2 6 1
Coordinates of p (x,y) = (0,0) 6 2 3 6 2
5 3 2 3 5
Coordinates of q (s,t) = (4,4)
2 4 3 5 2
4 5 2 3 6(q)
Amity School of Engineering & Technology
City Block Distance = D4 = |x-s| + |y-t|
D4 = |0-4| + |0-4| =8 units
Chessboard Distance = D8 = max{|x-s| + |y-t|}
D8 = max{4,4} = 4 units
(i) Dm = There is no path between p and q as q(6) is not included
in the set V {2,3}
(ii) Dm = There is no path between p and q
Amity School of Engineering & Technology
Question 2
An Image segment is shown
below. Let V be the set of values
used to define connectivity in the 3 1 2 1 (q)
image. Compute D4 ,D8, Dm
between pixels ‘p’ and ‘q’ for 0 2 0 2
(i) V= {0,1} 1 2 1 1
(ii) V = {1,2}
1 (p) 0 1 2
Amity School of Engineering & Technology
Solution:
Coordinates of p (x,y) = (0,0)
Coordinates of q (s,t) = (4,4)
City Block Distance = D4 = |x-s| + |y-t|
D4 = |0-3| + |0-3| =6 units
Chessboard Distance = D8 = max{|x-s| + |y-t|}
D8 = max{3,3} = 3 units
Dm = 5 units -> V{0,1}
Dm = 6 units -> V{1,2} (traverse all possible paths and consider shortest path
Amity School of Engineering & Technology
Analog Image Processing Vs Digital Image Processing
Analog Image Processing Digital Image Processing
• The analog image processing is applied on analog signals and it processes • The digital image processing is applied to digital signals that work on analyzing
only two-dimensional signals. and manipulating the images.
• Analog signal is time-varying signals so the images formed under analog • It improves the digital quality of the image and intensity distribution is perfect in
image processing get varied. it.
• Digital image processing is a cheaper and fast image storage and retrieval
• Analog image processing is a slower and costlier process.
process.
• It uses good image compression techniques that reduce the amount of data
• Analog signal is a real-world but not good quality of images.
required and produce good quality of images
• It uses an image segmentation technique which is used to detect discontinuity
• It is generally continuous and not broken into tiny components.
which occurs due to a broken connection path.
Amity School of Engineering & Technology
Sampling and Quantization
• Mostly the output of the image sensors are in the form of
analog signals (continuous and not broken into segments)
• Now the problem is that we cannot apply digital image
processing and its techniques to an analog signal
• This is due to the fact that we cannot store the output of image
sensors which are in the form of analog signals because it
requires infinite memory to store a signal that have infinite
values
• So, we have to convert this analog signal into digital form.
Amity School of Engineering & Technology
Sampling and Quantization
• To create a digital image, we need to convert an analog signal into digital form. This conversion from analog to
digital form involves two process:
– Sampling: Digitization of coordinate values.
– Quantization: Digitization of amplitude values.
• The basic idea behind converting an analog signal to its digital signal is to convert both of its axis (x,y) into a
digital format.
• Since an image is continuous not just in its co-ordinates (x axis), but also in its amplitude (y axis), so the part that
deals with the digitizing of co-ordinates is known as sampling. And the part that deals with digitizing the
amplitude is known as quantization.
Amity School of Engineering & Technology
Sampling and Quantization
• A digital image is a two-dimensional array of size M x N where M is the number of rows and N is the
number of columns in the array. A digital image is made up of a finite number of discrete picture
elements called a pixel.
• The location of each pixel is given by coordinates (x, y) and the value of each pixel is given by
intensity value f. Hence, the elements in a digital image can be represented by f(x, y).
• Spatial Resolution: The term spatial resolution corresponds to the total number of pixels in the given
image. If the number of pixels is more, then the resolution of the image is more.
• Down-sampling: In the down-sampling technique, the number of pixels in the given image is reduced
depending on the sampling frequency. Due to this, the resolution and size of the image decrease.
• Up-sampling: The number of pixels in the down-sampled image can be increased by using up-
sampling interpolation techniques. The up-sampling technique increases the resolution as well as the
size of the image.
Amity School of Engineering & Technology
Linear filters
• Linear filters are signal or image processing filters that implement linear operations, this therefore implies that the result produced by the filter is a
linear function of the input values. This means the filter’s response to a weighted sum of the inputs is equal to the weighted sum of the responses
of the filter to all inputs. Mathematically, if
• For purposes of analysis and computation, if x(t) is the input signal and h(t) is the filter’s impulse response the output of the convolution
yields y(t)=x(t)∗h(t). This property makes the linear filters superposition and homogeneous hence making them easily predictable when evaluated
mathematically.
• Features of Linear Filters:
• Superposition Principle: Given the literature, the response to the sum of inputs is the sum of the responses to each of the inputs separately.
• Homogeneity: The response given to a scaled input is also a scaled response to the input given.
• Convolution-Based: It must be noted that the output is obtained from the convolution of the input signal in the filter’s impulse response.
• Frequency Domain Analysis: Due to the non-random nature of signals which can be involved in the operation of systems they can be
easily analyzed and designed using frequency domain techniques like Fourier transform.
• Predictable Behavior: This means that they have a sequential order and their application makes them quite easy to anticipate and use in
different fields.
Amity School of Engineering & Technology
Applications of Linear filters
• Smoothing and Blurring: Applied within image processing to diminish the level of noise and detail
of the image. There are ordinary filters like Gaussian and averaging filters.
• Signal Filtering in Communication Systems: Hired to filter out unwanted components in
communication channels or rather in the information that is being sent from one terminal to the other.
• Edge Detection (Basic): Linear edge detectors like the Sobel filter enhance the edge by finding the
change in the intensity gradients.
• Data Smoothing: In this case, used in time series analysis to remove variability and to amplify trends
that may be underlying.
• Audio Signal Processing: Applied to balance the sounds; filtering out the noise or increasing the
frequency of certain tones.
Amity School of Engineering & Technology
Non-linear filters
• Non-linear filters can be defined as signal or image processing which does not consist of superposition and
homogeneity. This means that what they produce as output is not just a proportionate relation to the input values.
These filters apply operations that are functions of the inputs’ values and arrangement or other more complex
mathematical operations and algorithms. Nonlinear filters are more appropriate for jobs where certain kinds of
attributes need to be retained or other kinds of distortions need to be removed such as noise, edge detection and
image enhancement. In contrast to linear filters, their functioning is highly irregular and cannot be calculated with
the help of factors, which makes them functionally diverse but harder to study.
• Features of Non-linear Filters:
• Non-Superposition: The definition of a linear function gives a clear indication that the response of a system to a sum of inputs is not simply
the sum of the response to each input separately.
• Complex Operations: Some of those include operations like median filtering, morphological transformations and even adaptive filtering.
• Effective Noise Reduction: Superior in the removal of specific types of noise, for instance, of the salt and pepper type without distorting the
edges.
• Edge Preservation: Able to maintain or even sharpen edges and small features in the picture.
• Adaptive Behavior: Can adjust their processing according to the input characteristics of the local environment and therefore ideal for
complex and diverse data.
Amity School of Engineering & Technology
Applications of non-linear filters
• Noise Reduction (Salt-and-Pepper Noise): It is shown that the median filters can be used to
eliminate salt-and-pepper noise from images without smearing out boundaries.
• Edge Detection (Advanced): Non-linear filters such as morphological operators help in enhancing
edges in a much better way as compared to Linear filters.
• Image Enhancement: These convey techniques that work to enhance the brightness of the pictures in
addition to the exposure of features on the pictures.
• Medical Image Processing: By using non-linear filters, the features of the image can be amplified
and more so reduce noise in all forms of medical imaging including the MRI and CT scans.
• Adaptive Filtering: This is commonly applied in cases where the filter parameters change with the
nature of the signal as in recognition of spoken words.
Amity School of Engineering & Technology
Difference between Linear and Non-Linear Filters
Parameter Linear Filters Non-linear filters
Superposition Principle Obeys superposition principle Does not obey superposition principle
Homogeneity Response is proportional to the input Response is not necessarily proportional
Mathematical Basis Based on linear algebra and convolution Based on complex mathematical functions
Frequency Domain
Can be analyzed using Fourier Transform Not easily analyzed using Fourier Transform
Analysis
Output Predictability Predictable and straightforward to analyze Less predictable, complex analysis required
Noise Reduction Moderate noise reduction, can blur edges Effective at noise reduction, preserves edges
Edge Preservation Can blur edges Excels at preserving or enhancing edges
Computational Complexity Generally lower complexity Higher computational complexity
Adaptive Behavior Static, does not adapt to input characteristics Can adapt to local input characteristics
Impulse Response Defined impulse response (h(t)) No defined impulse response
Implementation Simpler to implement More complex to implement
Examples Mean filter, Gaussian filter Median filter, morphological filters