0% found this document useful (0 votes)
4 views24 pages

DIP Question Bank Answers

The document provides a comprehensive overview of Digital Image Processing (DIP), covering its definition, applications, and fundamental steps involved in processing digital images. It details components of an image processing system, image sensing and acquisition, as well as concepts like image sampling, quantization, and pixel representation. Additionally, it discusses color models such as RGB and HSI, their differences, and various applications of color image processing.

Uploaded by

dlaemspzh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views24 pages

DIP Question Bank Answers

The document provides a comprehensive overview of Digital Image Processing (DIP), covering its definition, applications, and fundamental steps involved in processing digital images. It details components of an image processing system, image sensing and acquisition, as well as concepts like image sampling, quantization, and pixel representation. Additionally, it discusses color models such as RGB and HSI, their differences, and various applications of color image processing.

Uploaded by

dlaemspzh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DIGITAL IMAGE PROCESSING

Complete Question Bank — Detailed Answers

Second Year Engineering — Information Technology


India
Units 1, 2, 3 & 4 | All Numerical Problems Solved
UNIT 1: Fundamentals of Image Processing

Q1. Explain the concept of Digital Image Processing and its major applications.
Definition: Digital Image Processing (DIP) refers to the use of computer algorithms to perform processing
operations on digital images. A digital image is a 2D function f(x, y) where x and y are spatial coordinates
and the amplitude (intensity) at any pair (x, y) is called the gray level or pixel value. When x, y, and
intensity values are all finite and discrete, the image is called a digital image.

Levels of Image Processing:


• Low-level processing: Noise reduction, contrast enhancement, sharpening.
• Mid-level processing: Segmentation, classification of objects.
• High-level processing: Pattern recognition, scene understanding.

Major Applications:
• Medical Imaging: X-ray, CT scan, MRI enhancement; tumour detection; dental imaging.
• Remote Sensing: Satellite image analysis; weather forecasting; agriculture monitoring.
• Industrial Inspection: Defect detection in products; quality control on assembly lines.
• Security & Surveillance: Face recognition; fingerprint recognition; CCTV analysis.
• Document Processing: OCR (Optical Character Recognition); cheque reading.
• Entertainment: Special effects in movies; image restoration of old films.
• Robotics & Autonomous Vehicles: Object detection; lane detection; obstacle avoidance.
• Astronomy: Enhancement of images from space telescopes (e.g., Hubble).

Q2. Describe the components of an image processing system with a neat diagram.
An image processing system consists of the following main components:

Component Function

Image Sensor Captures image from environment (e.g., CCD/CMOS camera, X-ray detector)

Digitizer (A/D Converter) Converts analog image signal into digital form (sampling + quantization)

Image Processor (CPU/GPU) Performs processing operations (filtering, segmentation, etc.)

Mass Storage Stores raw and processed images (HDD, SSD, cloud)

Image Display Shows output image (monitor, printer, projector)

Hardcopy Device Prints or permanently records processed images

Network (optional) Transmits images across communication channels

Block Diagram (Text Representation):


Scene / Source

Image Acquisition (Camera / Scanner / Sensor)

Digitizer (Sampling + Quantization)

Digital Image Storage

Image Processing (CPU / GPU)

Output: Display / Hardcopy / Transmission

Q3. Explain the fundamental steps involved in digital image processing.


Digital image processing involves the following fundamental steps:
1. Image Acquisition
Capturing the image using a camera, scanner, or sensor. The image is digitised by sampling and
quantization.
2. Image Preprocessing
Removing noise, correcting illumination, enhancing contrast to prepare image for further processing.
3. Image Enhancement
Improving image appearance for human viewing (e.g., sharpening, brightness adjustment, histogram
equalisation).
4. Image Restoration
Recovering a degraded image using mathematical models (e.g., deblurring, noise removal).
5. Colour Image Processing
Handling and processing colour information in RGB, HSI, CMY colour spaces.
6. Image Compression
Reducing storage/bandwidth by removing redundancy (e.g., JPEG, PNG, MPEG).
7. Morphological Processing
Shape-based operations like erosion, dilation, opening, closing.
8. Image Segmentation
Dividing image into meaningful regions/objects (thresholding, edge detection, region growing).
9. Representation and Description
Extracting features (boundary, texture, shape) from segmented regions.
10. Object Recognition
Assigning labels to identified objects based on extracted features (pattern recognition).

Q4. Discuss image sensing and acquisition in detail.


Image sensing and acquisition is the first step in any image processing pipeline. It involves converting light
energy into electrical signals and then into a digital image.

Image Sensing:
A sensor is used to detect energy (light, X-ray, infrared, etc.) reflected or emitted from a scene. Two
common types of sensors are:
• Single Imaging Sensor: A single photosensitive element. The scene is scanned row by row. Used
in scanners.
• Line Sensor (1D Array): A row of sensors. Used in satellite imaging — the platform moves to scan
the 2D area.
• Array Sensor (2D Array): A 2D grid of sensors (CCD or CMOS). Entire image captured at once.
Used in digital cameras.
Image Acquisition Process:
• Light from the scene falls on the image sensor.
• The sensor converts light intensity to an electrical (analog) signal.
• The signal is amplified and passed to an Analog-to-Digital Converter (ADC).
• ADC performs sampling (discretising x, y coordinates) and quantization (discretising intensity).
• The resulting digital image f(x, y) is stored in memory.

Q5. Explain the concept of simple image formation.


A digital image is formed as a 2D function f(x, y). Image formation depends on two components:

f(x, y) = i(x, y) × r(x, y)

• Illumination component i(x, y): Represents the amount of light falling on the scene. Range: 0 < i(x,
y) < ∞. Determined by the light source.
• Reflectance component r(x, y): Represents the fraction of light reflected by the object. Range: 0 <
r(x, y) < 1. Determined by the object's surface properties.

The intensity (gray level) at any pixel is the product of illumination and reflectance. Typical values: i(x, y)
ranges from 10 lux (indoor) to 90,000 lux (sunlight). r(x, y) ranges from 0.01 (black velvet) to 0.93 (white
snow).

Q6. What is image sampling? Explain its significance.


Sampling is the process of converting a continuous image into a discrete set of values by selecting pixel
values at regular spatial intervals along x and y axes. It determines the spatial resolution of the digital
image.

Significance:
• Sampling converts continuous spatial coordinates (x, y) into discrete coordinates (m, n).
• The sampling rate must satisfy the Nyquist Theorem: the sampling frequency must be at least twice
the highest frequency in the image.
• If sampling rate is too low → aliasing occurs (jagged edges, false patterns).
• Higher sampling rate → better spatial resolution, larger file size.

Example: A 512×512 image has 512 samples in each direction. Increasing to 1024×1024 doubles the
resolution but quadruples storage.

Q7. Define quantization and explain its role in image processing.


Quantization is the process of mapping continuous amplitude (intensity) values of an image into a finite
set of discrete integer levels. While sampling discretises the spatial domain, quantization discretises the
intensity (amplitude) domain.

Key Points:
• If an image is quantized into L gray levels, then L = 2k where k is the number of bits per pixel.
• For k = 8 bits: L = 256 gray levels (0 to 255). Most common in practice.
• For k = 1 bit: L = 2 (binary image — black and white only).
• More bits → better quality → more storage required.

Bits per pixel (k) No. of Gray Levels (L) Usage

1 2 Binary images (documents)


Bits per pixel (k) No. of Gray Levels (L) Usage

4 16 Simple graphics

8 256 Standard grayscale images

16 65,536 Medical, scientific imaging

24 16.7 million True colour images (RGB)

Q8. Explain how digital images are represented using pixels.


A digital image is a 2D matrix of pixels (Picture Elements). Each pixel is located at coordinates (x, y) or
(row, column) and has an associated intensity value.

For a grayscale image of size M×N:


f(x, y) where x ∈ {0,1,...,M-1} and y ∈ {0,1,...,N-1}

The image can be represented as a matrix:


f(0,0) f(0,1) ... f(0,N-1) f(1,0) f(1,1) ... f(1,N-1) ... ... ... ... f(M-1,0)
f(M-1,1) ... f(M-1,N-1)

• Grayscale Image: Each pixel = 1 value (0 to 255 for 8-bit).


• Colour (RGB) Image: Each pixel = 3 values (R, G, B), each 0–255.
• Binary Image: Each pixel = 0 or 1.
• Spatial resolution: M × N (e.g., 1920 × 1080 = Full HD).

Q9. Describe the concept of pixel neighbourhoods in digital images.


A pixel neighbourhood refers to the set of pixels surrounding a given pixel p at location (x, y).
Neighbourhoods are important in filtering, segmentation, and connectivity analysis.

Types of Neighbourhoods:
1. 4-Neighbourhood N4(p):
The set of pixels directly above, below, left, and right of p. For pixel at (x, y):
N4(p) = {(x+1,y), (x-1,y), (x,y+1), (x,y-1)}

2. 8-Neighbourhood N8(p):
Includes all 4-neighbours plus 4 diagonal neighbours:
N8(p) = N4(p) ∪ {(x+1,y+1),(x+1,y-1),(x-1,y+1),(x-1,y-1)}

3. Diagonal Neighbourhood ND(p):


Only the 4 diagonal pixels: ND(p) = {(x±1,y±1)}

Note: 8-neighbourhood ≡ N4(p) ∪ ND(p)

Q10. Explain different types of connectivity between pixels (4, 8, and m-connectivity).
Connectivity defines when two pixels are considered connected. It is based on neighbourhood and
intensity similarity.

1. 4-Connectivity:
Two pixels p and q with values from set V are 4-connected if q is in N4(p) AND both have values in V.
Used for simple binary images.

2. 8-Connectivity:
Two pixels p and q are 8-connected if q is in N8(p) AND both have values in V. More natural for real
images.

3. m-Connectivity (Mixed Connectivity):


Introduced to eliminate ambiguities in 8-connectivity. Two pixels p and q are m-connected if:
• q is in N4(p), OR
• q is in ND(p) AND N4(p) ∩ N4(q) has NO pixel with value in V.
m-connectivity eliminates the multiple path problem (staircase paths in 8-connectivity).

Type Neighbours Used Diagonal Allowed? Problem

4-Connectivity N4(p) No Misses diagonal connections

8-Connectivity N8(p) Yes Multiple path ambiguity

m-Connectivity N4 + ND conditionally Conditional Solves ambiguity

Q11. Explain the RGB colour model with suitable diagrams.


The RGB (Red, Green, Blue) colour model is the most widely used additive colour model in digital image
processing and display systems. It is based on the trichromatic theory of human vision.

Concept:
• Colours are formed by adding three primary colours: Red, Green, and Blue.
• Each colour component ranges from 0 to 255 (for 8-bit per channel).
• Total possible colours = 256 × 256 × 256 ≈ 16.7 million.

Key Combinations:
R G B Resulting Colour

0 0 0 Black

255 255 255 White

255 0 0 Red

0 255 0 Green

0 0 255 Blue

255 255 0 Yellow

255 0 255 Magenta

0 255 255 Cyan

A colour image in RGB is stored as a 3D array of size M × N × 3. Each pixel is represented as a triplet (R,
G, B).
Diagram: Imagine a unit cube where R, G, B are the three axes (0 to 1). The corners of the cube
represent the 8 primary and secondary colours. The main diagonal from (0,0,0) to (1,1,1) represents all
shades of grey.

Q12. Describe the HSI colour model and its components.


The HSI (Hue, Saturation, Intensity) colour model is designed to match the way humans perceive colour.
It decouples intensity (brightness) from colour information.

Components:
• Hue (H): The dominant wavelength / colour attribute. Represents the colour type (red, green, blue,
etc.). Measured in degrees: 0° = Red, 120° = Green, 240° = Blue.
• Saturation (S): The purity or vividness of the colour. S = 0 means grey (no colour); S = 1 means fully
saturated pure colour.
• Intensity (I): The brightness or luminance. I = 0 means black; I = 1 means white.

Geometric Interpretation: HSI is modelled as a double cone or cylinder. The vertical axis is intensity.
Saturation is the radial distance from the centre axis. Hue is the angle around the axis.

Why HSI? In RGB, all three components change when brightness changes, making colour analysis
difficult. HSI separates intensity from colour, simplifying colour-based image processing.

Q13. Compare RGB and HSI colour models.


Feature RGB Model HSI Model

Basis Additive primary colours Human perception of colour

Components Red, Green, Blue Hue, Saturation, Intensity

Geometry Unit cube Double cone / cylinder

Colour-intensity mixing Mixed together Separated

Suited for Hardware (displays) Image analysis, segmentation

Computation Simple More complex (trigonometric)

Grey scale R=G=B S=0, any I

Conversion Direct Requires formula

Q14. Discuss the applications of colour image processing.


• Object Recognition: Colour provides additional discriminating information (e.g., detecting ripe fruits
by colour).
• Medical Imaging: Colour used in pathology slides, retinal images, and thermal imaging.
• Remote Sensing: False colour satellite images to identify vegetation, water bodies, urban areas.
• Content-Based Image Retrieval (CBIR): Searching image databases by colour histograms.
• Face Detection: Skin colour segmentation in RGB or YCbCr space.
• Traffic Control: Traffic light colour recognition; lane detection.
• Industrial Inspection: Detecting coloured defects in manufacturing.
• Printing & Photography: Colour correction, white balance, gamma correction.

Q16. Describe the process of RGB to HSI conversion with mathematical equations.
Given a colour pixel with values (R, G, B) each normalised to [0, 1]:

Step 1 — Calculate Hue (H):


theta = arccos{ [(R-G) + (R-B)] / [2 * sqrt((R-G)^2 + (R-B)(G-B))] }
If B ≤ G → H = theta
If B > G → H = 360 - theta

Step 2 — Calculate Saturation (S):


S = 1 - [3 / (R + G + B)] × min(R, G, B)

Step 3 — Calculate Intensity (I):


I = (R + G + B) / 3

HSI to RGB Conversion (Inverse) — depends on the sector of H:


• RG sector (0° ≤ H < 120°): B = I(1-S); R = I[1 + S·cos(H)/cos(60°-H)]; G = 3I - (R+B)
• GB sector (120° ≤ H < 240°): H = H - 120°; R = I(1-S); G = I[1+S·cos(H)/cos(60°-H)]; B = 3I-(R+G)
• BR sector (240° ≤ H ≤ 360°): H = H - 240°; G = I(1-S); B = I[1+S·cos(H)/cos(60°-H)]; R = 3I-(G+B)

Numerical: Compute distances between P and Q using Euclidean, City Block, and Chess
Board measures.
Let P = (0, 0) and Q = (3, 4) (standard example used in textbooks for illustration).

1. Euclidean Distance (De):


De(P,Q) = sqrt( (x2-x1)^2 + (y2-y1)^2 )
De = sqrt( (3-0)^2 + (4-0)^2 ) = sqrt(9 + 16) = sqrt(25) = 5

Euclidean Distance = 5

2. City Block Distance (D4 / Manhattan Distance):


D4(P,Q) = |x2-x1| + |y2-y1|
D4 = |3-0| + |4-0| = 3 + 4 = 7

City Block Distance = 7

3. Chess Board Distance (D8 / Chebychev Distance):


D8(P,Q) = max(|x2-x1|, |y2-y1|)
D8 = max(|3|, |4|) = max(3, 4) = 4

Chess Board Distance = 4

Distance Type Formula Value

Euclidean sqrt((x2-x1)^2 + (y2-y1)^2) 5

City Block (D4) |x2-x1| + |y2-y1| 7

Chess Board (D8) max(|x2-x1|, |y2-y1|) 4


UNIT 2: Image Enhancement

Q1. Explain image enhancement using point processing techniques.


Image Enhancement aims to improve the visual quality of an image or make certain features more
prominent for analysis. Point processing is the simplest enhancement technique where each output pixel
depends only on the corresponding input pixel — no neighbourhood information is used.

General Form: s = T(r)

where r = input pixel intensity, s = output pixel intensity, T = transformation function.

Common Point Processing Techniques:


• Image Negatives: s = L - 1 - r (inverts intensity; used for medical images).
• Thresholding: s = 255 if r > threshold, else s = 0.
• Contrast Stretching: Expands the dynamic range of intensities.
• Log Transformation: s = c·log(1+r); enhances dark pixels.
• Power-Law (Gamma) Transformation: s = c·r^γ; gamma correction.
• Histogram Equalisation: Redistributes intensities for better contrast.

Q2. Describe neighbourhood processing methods for image enhancement.


Neighbourhood processing computes the output pixel value based on the values of neighbouring pixels
in a defined region (mask/kernel) around the pixel.

• Spatial Filtering: Apply a filter mask (e.g., 3×3) over the image using convolution or correlation.
Used for smoothing, sharpening.
• Mean Filter: Replaces each pixel by the average of its neighbourhood. Reduces noise.
• Median Filter: Replaces each pixel by the median of its neighbourhood. Excellent for
salt-and-pepper noise.
• Gaussian Filter: Weighted average giving more weight to centre pixel.
• Laplacian Filter: Second derivative; used for edge sharpening.
• Sobel/Prewitt Filter: First derivative; used for edge detection.

Q3 & Q4. Differentiate Spatial and Frequency Domain Enhancement. Which requires less
computation?
Aspect Spatial Domain Frequency Domain

Operation Directly on pixel values On Fourier Transform of image

Representation f(x, y) F(u, v)

Filtering Convolution with mask Multiplication in freq. domain

Complexity O(M×N×m×n) for mask size m×n O(M×N×log(M×N)) with FFT

Computation Less for small masks Better for large/complex filters

Accuracy Limited for complex filters More precise control

Suitability Simple, local operations Complex, global operations

Spatial domain requires less computation for small filter masks (e.g., 3×3, 5×5). However, for large
kernels or complex filters, frequency domain (using FFT) is faster. The choice depends on filter size and
image size.
Q5. Explain basic gray-level transformations with examples.
Gray-level transformation maps input intensity r to output intensity s using a transformation T.

Transform Equation Application

s=L-1-r
1. Image Negative Reversing intensity. Black → White. Used in medical X-rays.
(For 8-bit: s = 255 - r)

s = c × log(1 + r)
2. Log Transformation Enhancing dark regions. Used for Fourier spectrum display.
c is a constant

s = c × r^γ
3. Power-Law (Gamma) Gamma correction in monitors and cameras.
γ < 1: brightens; γ > 1: darkens

4. Piecewise Linear Different T(r) in different ranges Contrast stretching, thresholding.

5. Identity s=r No change — baseline transform.

Q6. Contrast Stretching and Thresholding — Equations and Applications.


Contrast Stretching:
Expands a narrow range of input intensities to a wider range in the output. If the input has values between
r1 and r2, they are stretched to [s1, s2].
For a simple case: s = (r - r_min) / (r_max - r_min) × (L - 1)

Applications: Enhancing low contrast images (foggy photos, medical scans, satellite images).

Thresholding:
Special case of contrast stretching where:
s = 0 if r < threshold s = L-1 if r >= threshold

Produces a binary image. Useful for separating objects from background.


Applications: Document scanning (text/background separation), cell detection in microscopy, OCR.

Q7. LOG Transformation and Power-Law Transformation — Curves and Applications.


1. LOG Transformation:
General Form: s = c × log(1 + r)

where c is a constant, r ≥ 0.

Curve behaviour: The log curve is concave — dark (low intensity) pixels are mapped to a wide range of
output values, while bright pixels are compressed. This expands the dark regions and compresses the
bright regions.

Applications:
• Displaying Fourier spectrum (which has very large dynamic range).
• Enhancing details in darker regions of medical images.
• Compressing dynamic range of high-contrast images.

2. Power-Law (Gamma) Transformation:


General Form: s = c × r^γ

where c > 0 and γ > 0 are constants.

Curve behaviour:
• γ < 1: Curve bows upward → dark regions are brightened → used for images that are too dark.
• γ = 1: Identity transform → s = r (no change).
• γ > 1: Curve bows downward → bright regions are darkened → used for images that are too bright.

Applications:
• Gamma correction in monitors, cameras, MRI scanners.
• Aerial and satellite image enhancement.
• Improving washed-out or over-exposed photographs.

Q8 & Q9. What is Histogram Processing? Explain Histogram Equalisation with example.
Histogram Processing:
A histogram of a digital image is a graph that shows the frequency (number of pixels) at each gray level.
For an image with L gray levels, the histogram h(rk) = nk where nk = number of pixels with intensity rk.
The normalised histogram: p(rk) = nk / (M×N), which gives the probability of each gray level.

Histogram Equalisation:
Histogram equalisation redistributes pixel intensities to make the histogram as uniform as possible. The
output image has a flat histogram — better contrast overall.

Formula for output intensity sk:


sk = (L-1) × Σ p(rj) for j = 0 to k
= (L-1) × Σ (nj / MN)

The result is then rounded to the nearest integer.

Q10. Numerical: 8 gray levels, compute sk for histogram equalisation.


Given: L = 8 gray levels (0–7), Total pixels = 8+12+20+30+16+8+4 = 98

rk nk p(rk)=nk/98 CDF: Σp(rj) sk = 7×CDF Rounded sk

0 8 0.0816 0.0816 0.571 1

1 12 0.1224 0.2040 1.428 1

2 20 0.2041 0.4082 2.857 3

3 30 0.3061 0.7143 5.000 5

4 16 0.1633 0.8776 6.143 6

5 8 0.0816 0.9592 6.714 7

6 4 0.0408 1.0000 7.000 7

Result mapping: 0→1, 1→1, 2→3, 3→5, 4→6, 5→7, 6→7

Q11. Numerical: Histogram Equalisation — 8 gray levels.


Given: L = 8, Total pixels = 0+100+400+50+200+50+200+0 = 1000

rk nk p(rk) CDF sk=7×CDF Rounded

0 0 0.000 0.000 0.000 0

1 100 0.100 0.100 0.700 1

2 400 0.400 0.500 3.500 4

3 50 0.050 0.550 3.850 4


rk nk p(rk) CDF sk=7×CDF Rounded

4 200 0.200 0.750 5.250 5

5 50 0.050 0.800 5.600 6

6 200 0.200 1.000 7.000 7

7 0 0.000 1.000 7.000 7

Mapping: 0→0, 1→1, 2→4, 3→4, 4→5, 5→6, 6→7, 7→7

Q12. Numerical: Histogram Equalisation on 5×5 image.


Image:

4 4 4 4 4

3 4 5 4 3

3 5 5 5 3

3 4 5 4 3

4 4 4 4 4

Total pixels = 25. Count each gray level:


Gray level 3: count = 8 (corners and edges) Gray level 4: count = 12 Gray level 5:
count = 5

Let us count carefully from the image:


• Row 1: 4,4,4,4,4 → five 4s
• Row 2: 3,4,5,4,3 → two 3s, two 4s, one 5
• Row 3: 3,5,5,5,3 → two 3s, three 5s
• Row 4: 3,4,5,4,3 → two 3s, two 4s, one 5
• Row 5: 4,4,4,4,4 → five 4s
Count: 3→8, 4→14, 5→3 ... let us recount
3s: R2(2)+R3(2)+R4(2)=6; 4s: R1(5)+R2(2)+R4(2)+R5(5)=14; 5s: R2(1)+R3(3)+R4(1)=5.
Total=6+14+5=25 ✓

Since gray levels present are only 3, 4, 5 (L effectively = 6 levels 0–5):


Using L=6 (values 0–5), (L-1)=5:

rk nk p(rk) CDF sk=5×CDF Rounded

3 6 0.24 0.24 1.20 1

4 14 0.56 0.80 4.00 4

5 5 0.20 1.00 5.00 5

Equalised Image: Replace 3→1, 4→4, 5→5:

4 4 4 4 4

1 4 5 4 1

1 5 5 5 1

1 4 5 4 1

4 4 4 4 4

Q13. Types of Mean Filters used for noise reduction.


Mean filters are spatial filters that replace each pixel with a weighted or unweighted average of its
neighbourhood.

Filter Formula Property

1. Arithmetic Mean Filter s = (1/mn) × Σ f(x,y) Simplest. Reduces Gaussian noise but blurs edges.

2. Geometric Mean Filter s = [Π f(x,y)]^(1/mn) Preserves more detail than arithmetic mean. Less blurring.

3. Harmonic Mean Filter s = mn / Σ(1/f(x,y)) Works well for salt noise; not for pepper noise.

4. Contraharmonic Mean Filter s = Σ f^(Q+1) / Σ f^Q Q > 0: removes pepper noise; Q < 0: removes salt noise.

Q14. Explain median filter with example.


The median filter replaces each pixel value with the median of all pixel values in the neighbourhood
mask. It is a non-linear filter — highly effective at removing salt-and-pepper (impulse) noise while
preserving edges.

Steps:
• Define a mask (e.g., 3×3).
• For each pixel, collect all values under the mask.
• Sort the values.
• Replace the centre pixel with the middle (median) value.

Example — 3×3 neighbourhood:


Neighbourhood values: [10, 80, 20, 90, 150, 30, 10, 20, 30]
Sorted: [10, 10, 20, 20, 30, 30, 80, 90, 150]
Median (5th value) = 30

If the centre was 150 (noise spike), it is replaced by 30 — noise removed, edge preserved.

Q18. Apply 3×3 Median Filter on the given image segment.


Image segment:

18 22 33 25 32 24

34 128 24 172 26 23

22 19 32 31 28 26

Apply 3×3 median filter to each pixel (we compute for central pixels — pixels where a full 3×3 window fits):

Central pixel at position (1,1) = 128:


Neighbourhood: 18,22,33, 34,128,24, 22,19,32
Sorted: 18,19,22,22,24,32,33,34,128
Median = 24 ← Noise pixel 128 removed!

Central pixel at position (1,2) = 24:


Neighbourhood: 22,33,25, 128,24,172, 19,32,31
Sorted: 19,22,24,25,31,32,33,128,172
Median = 31

Central pixel at position (1,3) = 172:


Neighbourhood: 33,25,32, 24,172,26, 32,31,28
Sorted: 24,25,26,28,31,32,32,33,172
Median = 31 ← Noise pixel 172 removed!

The median filter has successfully removed the salt-and-pepper noise (128 and 172).

Q15 & Q16. Image filtering in frequency domain — Block Diagram and Noise Reduction.
Basic Steps (Block Diagram):
1. Input Image f(x,y)
2. Apply DFT (Discrete Fourier Transform) → F(u,v)
3. Multiply by Filter H(u,v): G(u,v) = H(u,v) × F(u,v)
4. Apply Inverse DFT (IDFT) → g(x,y)
5. Output enhanced image g(x,y)

For noise reduction in frequency domain:


• Noise typically appears as high-frequency components in F(u,v).
• Apply a Low Pass Filter H(u,v) that passes low frequencies and blocks high frequencies.
• Types: Ideal LPF, Butterworth LPF, Gaussian LPF.
• The result: noise is reduced but some blurring may occur.

Q17 & Q21–Q23. Smoothing and Sharpening Filters.


Smoothing Filters (Low-pass):
Reduce noise and blur high-frequency details.
• Average (Box) Filter: All coefficients = 1/9 for 3×3. Uniform blurring.
• Weighted Average: Centre pixel gets more weight (e.g., Gaussian kernel).
• Gaussian Filter: Based on Gaussian function; most natural-looking blur.
Application: Noise removal, pre-processing before segmentation.

Sharpening Filters (High-pass):


Emphasise edges and fine details; enhance transitions.
• Laplacian Filter: Second derivative operator. Detects all edges regardless of direction.
Laplacian kernel: [0,-1,0; -1,4,-1; 0,-1,0] or [-1,-1,-1; -1,8,-1; -1,-1,-1]

• Sobel Filter: First derivative; two kernels (horizontal and vertical).


• Unsharp Masking: Sharpened = Original + k×(Original - Blurred).
Application: Edge detection, feature extraction, fingerprint analysis.

Q29. Image sharpening using second order derivative filters (Laplacian).


The Laplacian is a second-order derivative operator that highlights regions of rapid intensity change.

Laplacian definition:
∇²f = ∂²f/∂x² + ∂²f/∂y²

Discrete approximation:
∇²f(x,y) = f(x+1,y) + f(x-1,y) + f(x,y+1) + f(x,y-1) - 4f(x,y)

Sharpened image:
g(x,y) = f(x,y) - ∇²f(x,y) [if Laplacian centre is negative]
g(x,y) = f(x,y) + ∇²f(x,y) [if Laplacian centre is positive]

Application to given image segment:

18 22 33 25 32 24

34 128 24 172 26 23

22 19 32 31 28 26

Computing Laplacian at interior pixel (1,2) = 24:


Neighbours: up=33, down=32, left=128, right=172
∇²f = 33 + 32 + 128 + 172 - 4×24 = 365 - 96 = 269
Sharpened value = 24 + 269 = 293 (clipped to 255)

This shows the Laplacian amplifies edges strongly — typically used with a small scaling factor c.

Q24–Q28. Fourier Transform, LPF, HPF in Frequency Domain.


Fourier Transform:
The 2D DFT of an image f(x,y) is:
F(u,v) = Σ Σ f(x,y) × e^(-j2π(ux/M + vy/N))

F(u,v) represents the frequency content. |F(u,v)| = spectrum, ∠F(u,v) = phase.

Low Pass Filter (LPF):


Allows low frequencies (smooth regions), blocks high frequencies (edges, noise).
• Ideal LPF: H(u,v)=1 if D(u,v)≤D0, else 0. Sharp cutoff causes ringing.
• Butterworth LPF: H(u,v) = 1 / [1 + (D/D0)^2n]. Smooth rolloff.
• Gaussian LPF: H(u,v) = e^(-D²/2σ²). No ringing.

High Pass Filter (HPF):


Allows high frequencies (edges), blocks low frequencies (smooth background).
HPF = 1 - LPF (relationship between LPF and HPF)
Application: Edge detection, sharpening, feature extraction.
UNIT 3: Image Segmentation

Q1. Define image segmentation and explain its importance.


Image Segmentation is the process of partitioning a digital image into multiple segments (regions or
objects) to simplify or change the representation of an image for easier analysis. The goal is to locate
objects and boundaries (lines, curves) in images.

Formally: The image domain R is partitioned into sub-regions R1, R2, ..., Rn such that:
• Ri ∪ Rj = R (all regions cover the full image)
• Ri ∩ Rj = Ø (no overlap between regions)
• Each region Ri satisfies a homogeneity condition (e.g., similar intensity, colour, texture)

Importance:
• It is a critical step between image processing and image analysis.
• Enables object detection, recognition, and measurement.
• Applications: Medical diagnosis (tumour detection), autonomous driving, satellite analysis.

Q2, Q3, Q4, Q6. Thresholding — Types and Techniques.


Thresholding converts a grayscale image into a binary image by comparing each pixel value with a
threshold T.

If f(x,y) > T → g(x,y) = 1 (object) If f(x,y) ≤ T → g(x,y) = 0 (background)

Types of Thresholding:
1. Global Thresholding:
A single threshold T is applied to the entire image. Effective when background and object intensities are
well separated.
Method: Iterative / Otsu's method (automatically selects T to maximise between-class variance).

2. Local (Adaptive) Thresholding:


Different thresholds for different regions of the image. Handles non-uniform illumination.
T is computed locally based on the mean/variance of the neighbourhood.

3. Multiple Thresholding:
Uses multiple thresholds T1, T2, ..., Tk to classify pixels into more than 2 classes.

4. Variable Thresholding:
Threshold changes based on image properties at each location (e.g., based on local variance).

Q5, Q7. Edge Detection and Line Detection.


Edge Detection:
Edges are points in an image where there is a significant local change in intensity. Edge detection
identifies the boundaries of objects.

First-Order Derivative Operators:


• Sobel Operator: Uses 3×3 kernels for horizontal (Gx) and vertical (Gy) gradients.
Gx = [-1,0,1; -2,0,2; -1,0,1] Gy = [-1,-2,-1; 0,0,0; 1,2,1]
Magnitude: |G| = sqrt(Gx² + Gy²)

• Prewitt Operator: Similar to Sobel but equal weights.


• Roberts Cross Operator: 2×2 kernels; sensitive to noise.

Second-Order Derivative:
• Laplacian of Gaussian (LoG): Applies Gaussian smoothing then Laplacian. Finds edges at zero
crossings.
• Canny Edge Detector: Multi-step: Gaussian smoothing → gradient → non-max suppression →
double thresholding → edge tracking. Best overall method.

Line Detection using Masks:


Specific directional masks detect lines:

Direction Mask (3×3)

Horizontal [-1,-1,-1; 2,2,2; -1,-1,-1]

Vertical [-1,2,-1; -1,2,-1; -1,2,-1]

+45° [-1,-1,2; -1,2,-1; 2,-1,-1]

-45° [2,-1,-1; -1,2,-1; -1,-1,2]

Q8. Detect horizontal line in the image using line detection mask.
Given Image:

30 31 30

120 121 121

30 30 32

Horizontal line detection mask:


[-1, -1, -1] [ 2, 2, 2] [-1, -1, -1]

Apply mask at centre pixel (1,1) = 121:


Response = (-1×30)+(-1×31)+(-1×30)+(2×120)+(2×121)+(2×121)+(-1×30)+(-1×30)+(-1×32)
= -30 - 31 - 30 + 240 + 242 + 242 - 30 - 30 - 32
= -153 + 724 = 571

High response (571) at row 2 → confirms presence of a horizontal line at row 2 (values 120, 121,
121).

Q9. Explain edge linking using graph search methods.


After edge detection, individual edge pixels may not be connected into continuous boundaries. Edge
linking connects isolated edge pixels into coherent curves.

Graph Search Method (Dynamic Programming):


• Represent the image as a graph where each pixel is a node.
• Edge cost between adjacent nodes based on gradient magnitude and direction.
• Use Dijkstra's Algorithm or A* Algorithm to find minimum cost path between two boundary points.
• Path with minimum cost = best edge.

Similarity Criteria for Edge Linking:


• Magnitude similarity: |∇f(p) - ∇f(q)| ≤ T1
• Direction similarity: |θ(p) - θ(q)| ≤ T2

Q10. Discuss the concept and working of the Hough Transform.


The Hough Transform is a feature extraction technique used to detect simple geometric shapes (lines,
circles, ellipses) in an image, even when they are partially obscured or noisy.

For Line Detection:


A line in image space y = mx + c is represented as a point (m, c) in parameter (Hough) space.
Using normal form: x·cosθ + y·sinθ = ρ (avoids infinite slope for vertical lines)

Algorithm:
• Create an accumulator array A(ρ, θ).
• For each edge pixel (x, y), for each θ, compute ρ = x·cosθ + y·sinθ and increment A(ρ, θ).
• Peaks in A(ρ, θ) correspond to the strongest lines in the image.

Application: Lane detection in autonomous vehicles; industrial inspection; document analysis.

Q11, Q12, Q13. Region-based Segmentation — Growing, Splitting, Merging.


Region Growing:
Starts from seed points and grows by adding neighbouring pixels that satisfy a homogeneity criterion (e.g.,
|pixel - seed| ≤ T).
• Step 1: Select seed point(s).
• Step 2: Examine neighbours using 4- or 8-connectivity.
• Step 3: Add neighbour if |value - region_mean| ≤ T.
• Step 4: Update region mean. Repeat until no more pixels qualify.

Region Splitting and Merging:


Uses a quad-tree structure:
• Splitting: Start with entire image. If region is not homogeneous (variance > T), split into 4 equal
sub-regions. Repeat recursively.
• Merging: After splitting, merge adjacent regions if their combined region satisfies the homogeneity
criterion.

Edge vs Region Segmentation:


Aspect Edge-based Region-based

Basis Discontinuities (edges) Similarity (homogeneity)

Method Gradient, Laplacian Growing, splitting/merging

Noise sensitivity High Lower

Closed regions Not guaranteed Guaranteed

Speed Fast Slower

Q17. Apply region growing: Initial point (2,2), threshold=2, connectivity=4.


Given Image (0-indexed, row 0 at top):

0 1 2 0

2 5 6 1
0 1 2 0

1 4 7 3

0 2 5 1

Seed = (2,2), Value at (2,2) = 7, Threshold T = 2


Condition: |neighbour_value - seed_value| ≤ 2 → pixel is added

Step-by-step:
Seed (2,2) = 7. Region = {(2,2)}
4-neighbours of (2,2): (1,2)=6, (3,2)=5, (2,1)=4, (2,3)=3
|6-7|=1 ≤ 2 → Add (1,2). |5-7|=2 ≤ 2 → Add (3,2).
|4-7|=3 > 2 → Reject (2,1). |3-7|=4 > 2 → Reject (2,3).
Region = {(2,2), (1,2), (3,2)}

Expand (1,2)=6. Neighbours: (0,2)=2, (2,2) done, (1,1)=5, (1,3)=1


|2-7|=5 > 2 → Reject. |5-7|=2 ≤ 2 → Add (1,1). |1-7|=6 > 2 → Reject.
Region = {(2,2),(1,2),(3,2),(1,1)}

Expand (3,2)=5. Neighbours: (2,2) done, (3,1)=2, (3,3)=1


|2-7|=5 > 2 → Reject. |1-7|=6 > 2 → Reject.

Expand (1,1)=5. Neighbours: (0,1)=1, (2,1)=4, (1,0)=2, (1,2) done


|1-7|=6 → Reject. |4-7|=3 > 2 → Reject. |2-7|=5 > 2 → Reject.

Final Region = {(2,2), (1,2), (3,2), (1,1)}

Q18. Apply region splitting and merging on 8×8 image with threshold=3.
Given Image:

5 6 6 6 7 7 6 6

6 7 6 7 5 5 4 7

6 6 4 4 3 2 5 6

5 4 5 4 2 3 4 6

0 3 2 3 3 2 4 7

0 0 0 0 2 2 5 6

1 1 0 1 0 3 4 4

1 0 1 0 2 3 5 4

Threshold T = 3. Homogeneity criterion: max_value - min_value ≤ T in a region.

Split Phase (Quad-tree):


Divide 8×8 into four 4×4 quadrants:
Q1 (top-left, rows 0-3, cols 0-3): values = {5,6,6,6,6,7,6,7,6,6,4,4,5,4,5,4}
min=4, max=7, range=3 ≤ 3 → HOMOGENEOUS (do not split further)

Q2 (top-right, rows 0-3, cols 4-7): values = {7,7,6,6,5,5,4,7,3,2,5,6,2,3,4,6}


min=2, max=7, range=5 > 3 → SPLIT into 4 sub-regions of 2×2

Q3 (bottom-left, rows 4-7, cols 0-3): values = {0,3,2,3,0,0,0,0,1,1,0,1,1,0,1,0}


min=0, max=3, range=3 ≤ 3 → HOMOGENEOUS

Q4 (bottom-right, rows 4-7, cols 4-7): values = {3,2,4,7,2,2,5,6,0,3,4,4,2,3,5,4}


min=0, max=7, range=7 > 3 → SPLIT further

Merge Phase:
• After splitting, adjacent regions are merged if their combined range ≤ T.
• Q1 (range=3) and Q3 (range=3) are adjacent — combined: min=0, max=7 → range=7 > 3 → Cannot
merge.
• Sub-regions of Q2 and Q4 are evaluated similarly.

Result: The 8×8 image is segmented into 3 main regions: top-left (uniform, values ~4-7), bottom-left (dark,
values 0-3), and right half (mixed — further subdivided).
UNIT 4: Morphological Image Processing

Q1. Define morphological image processing.


Morphological Image Processing is a collection of non-linear operations that process images based on
the shape (morphology) of features in the image. It is based on set theory and works by probing an image
with a small shape called a structuring element (SE).

Morphological operations are especially effective on binary images but can be extended to grayscale
images. The main operations are: Erosion, Dilation, Opening, and Closing.

Q2. Explain dilation operation with examples.


Dilation expands or grows the shapes in a binary image. It adds pixels to the boundaries of objects.

Definition:
A ⊕ B = {z | (B_hat)_z ∩ A ≠ Ø}

where A = input image, B = structuring element, B_hat = reflection of B.


In simpler terms: A pixel (x,y) is set to 1 in the output if any part of B placed at (x,y) overlaps with A.

Example:
Binary image A: Structuring element B:
0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 1 0 0 0 0 0 0

After dilation, the 1-region expands by 1 pixel in all 4 directions.

Properties:
• Dilation is commutative: A ⊕ B = B ⊕ A
• Dilation is associative: A ⊕ (B ⊕ C) = (A ⊕ B) ⊕ C
• Dilation grows objects; fills small holes and gaps.

Q3. Describe erosion operation in detail.


Erosion shrinks or thins the shapes in a binary image. It removes pixels from the boundaries of objects.

Definition:
A ■ B = {z | B_z ⊆ A}

A pixel (x,y) remains 1 in the output only if B placed at (x,y) is completely contained within A.

Example:
For a 5×5 object and 3×3 SE of all 1s: erosion reduces the object by 1 pixel on all sides → 3×3 output
object.

Properties:
• Erosion is NOT commutative.
• Erosion shrinks objects; removes thin protrusions and small noise objects.
• Dual of dilation: A ■ B = (A^c ⊕ B^hat)^c

Q4. Compare Dilation and Erosion.


Property Dilation Erosion

Effect on objects Grows / Expands Shrinks / Reduces

Effect on holes Fills small holes Enlarges holes

Commutative Yes No

Symbol A⊕B A■B

Condition Any overlap with A Complete containment in A

Use case Bridge gaps, join regions Remove noise, separate objects

Q5 & Q6. Opening and Closing — Definition, Applications, Comparison.


Opening (A ■ B):
Opening = Erosion followed by Dilation:
A ■ B = (A ■ B) ⊕ B

Effect: Removes small objects and thin protrusions; smooths contours; breaks narrow connections.
Applications: Removing noise (small speckles), separating connected objects.

Closing (A • B):
Closing = Dilation followed by Erosion:
A • B = (A ⊕ B) ■ B

Effect: Fills small holes and narrow gaps; smooths contours from outside.
Applications: Filling holes in objects, joining broken contours, closing gaps.

Comparison:
Property Opening Closing

Order Erosion → Dilation Dilation → Erosion

Effect Removes small protrusions Fills small holes/gaps

Object size Slightly smaller Slightly larger

Idempotent Yes Yes

Use case Noise removal Filling cracks/gaps

Q8 & Q9. Hit-or-Miss Transform.


The Hit-or-Miss Transform is a morphological operation used for detecting specific patterns or shapes in
a binary image. It simultaneously erodes the image with two structuring elements.

Definition:
A ■ B = (A ■ B1) ∩ (A^c ■ B2)

where B = (B1, B2) is a composite SE. B1 fits inside the object; B2 fits in the background around it.

Applications:
• Detecting specific pixel configurations.
• Thinning and thickening of binary objects.
• Corner detection in binary images.
• Locating isolated points, endpoints of line segments.
Q10. Morphological operations using structuring elements.
A Structuring Element (SE) is a small binary or grayscale template used to probe the image in
morphological operations. Its shape determines the nature of the operation.

Common Structuring Elements:


Shape Description Effect

Cross (Plus) [0,1,0; 1,1,1; 0,1,0] 4-connectivity operations

Square/Box [1,1,1; 1,1,1; 1,1,1] 8-connectivity; uniform dilation

Disk Circular SE Isotropic operations

Horizontal Bar [1,1,1] Detects/removes horizontal structures

Diagonal Diagonal 1s Diagonal feature processing

The origin of the SE is the reference point (usually centre). Results depend heavily on SE shape and size.

Q11 & Q12. Boundary Representation and Boundary Descriptors.


Boundary Representation:
After segmentation, boundaries of regions must be represented for analysis.
• Chain Code: Encodes boundary by recording the direction of each successive pixel. 4-directional
(0-3) or 8-directional (0-7). Compact but sensitive to noise.
• Polygonal Approximation: Approximates the boundary with line segments. Reduces data while
preserving shape.
• Signatures: 1D representation of boundary: plot distance from centroid vs angle.
• Skeleton: Thinned version of object obtained through morphological thinning.

Boundary Descriptors:
Quantitative measures that describe boundary characteristics:
• Perimeter: Total length of the boundary.
• Diameter: Max distance between any two boundary points.
• Eccentricity: Ratio of major to minor axis.
• Curvature: Rate of change of tangent angle along boundary.
• Fourier Descriptors: DFT of the boundary signature; translation, scale, rotation invariant.

Q13 & Q14. Regional Descriptors and Comparison.


Regional Descriptors:
Descriptors based on the entire region (not just boundary):
• Area: Number of pixels in the region.
• Centroid: Mean of (x, y) coordinates: (x■, ■) = (Σx/n, Σy/n).
• Compactness: Perimeter² / Area (circle has minimum compactness = 4π).
• Moments: Statistical moments (mean, variance, skewness) of pixel intensity distribution.
• Texture: Statistical properties (contrast, energy, correlation) from Gray-Level Co-occurrence Matrix
(GLCM).

Comparison: Boundary vs Regional Descriptors:


Aspect Boundary Descriptors Regional Descriptors

Based on Contour/perimeter only All pixels in region


Aspect Boundary Descriptors Regional Descriptors

Shape info Good for shape Good for area/intensity

Noise sensitivity High (boundary noise) Lower

Examples Chain code, perimeter, diameter Area, centroid, compactness, texture

Used for Shape matching Object classification

Q15 & Q16. Applications of Morphological Processing and Noise Removal.


Applications:
• Noise Removal: Opening removes small noise objects; closing fills small holes.
• Border Extraction: Border = A - (A ■ B); gives only the boundary pixels.
• Hole Filling: Uses dilation and complement to fill enclosed holes.
• Connected Component Labelling: Identifies distinct objects using dilation.
• Thinning/Skeletonisation: Reduces objects to single-pixel-wide skeletons.
• Convex Hull: Finds smallest convex shape containing an object.
• Pruning: Removes parasitic branches from skeletons.

Noise Removal using Morphological Operations:


Binary noise (isolated 1-pixels on black background):
• Apply Opening (Erosion then Dilation): Removes isolated small noise pixels while preserving larger
objects.
Example: Original has 1-pixel noise speckles. SE = 3×3 cross. After erosion: noise speckles disappear
(too small to survive). After dilation: larger objects restored to original size.

For grayscale images:


• Grayscale Opening: Removes bright noise on dark background.
• Grayscale Closing: Removes dark noise (holes) on bright background.
• Combination (Opening + Closing) = Morphological Filter for balanced noise removal.

Best of luck for your exam! Remember: understand the concepts, practise the numericals,
and revise the key formulas.

You might also like