Digital Image Processing
Module 1 — Complete Exam Notes
Lecture Duration: 8 Hours
Covers: Introduction • Digital Image Fundamentals
Topic Key Concepts
Introduction Background, Representation, Steps, System Elements
Visual Perception Human eye, Brightness adaptation, Mach bands
Image Model Illumination & Reflectance, f(x,y)
Sampling & Quantization Digitizing images, Bit depth, Nyquist
Pixel Relationships Neighbours, Connectivity, Distance measures
Imaging Geometry Perspective projection, Coordinates
SECTION 1: INTRODUCTION TO DIGITAL IMAGE PROCESSING
1.1 Background
Digital Image Processing (DIP) refers to using a computer to process digital images. An image is a 2D
function f(x, y) where x and y are spatial coordinates and f is the intensity (brightness) value at that point.
■ Example: A photograph on your phone is a digital image. Each tiny dot (pixel) has a brightness value. The
image of size 1920×1080 has about 2 million pixels!
Why do we process images?
• To improve image quality (remove noise, enhance contrast)
• To extract useful information (detect edges, count objects)
• For machine vision (robots, self-driving cars)
• Medical imaging: X-ray, MRI, CT scan analysis
• Remote sensing: satellite image analysis
1.2 Digital Image Representation
A digital image is represented as a 2D array (matrix) of numbers. Each element is called a pixel (picture
element).
f(x, y) where x = row (0 to M-1), y = column (0 to N-1) Image size = M rows
x N columns = M x N pixels
■ Example: A small 4×4 grayscale image: [ 0 50 100 150 ] [ 50 100 150 200 ] [100 150 200 250 ] [150 200
250 255 ] Here 0 = black, 255 = white, values in between = shades of gray.
Types of Images:
Type Pixel Values Example
Binary 0 or 1 only Text scan, fingerprint
Grayscale 0 to 255 (8-bit) X-ray, old photos
Color (RGB) 3 channels R, G, B each 0-255 Digital photos
Multispectral More than 3 bands Satellite images
1.3 Fundamental Steps in Digital Image Processing
There are 11 fundamental steps in DIP. Think of it as a pipeline — the image goes through several
stages:
1. Image Acquisition
Capturing the image using camera/scanner.
■ Example: Taking a photo with your smartphone camera.
2. Image Enhancement
Improving visual appearance for human viewing.
■ Example: Increasing brightness/contrast of a dark photo in Photoshop.
3. Image Restoration
Correcting degradation using mathematical models.
■ Example: Removing blur from a shaky photo.
4. Color Image Processing
Working with color models and transformations.
■ Example: Converting a color image from RGB to HSV.
5. Wavelets & Multiresolution
Representing images at different resolutions.
■ Example: JPEG 2000 image compression uses wavelets.
6. Compression
Reducing file size while preserving quality.
■ Example: JPEG compresses a 5 MB photo to 500 KB.
7. Morphological Processing
Tools for extracting image components.
■ Example: Removing small noise dots from a binary image.
8. Segmentation
Partitioning image into meaningful regions.
■ Example: Separating the background from a person in a photo.
9. Representation & Description
Choosing data to represent regions.
■ Example: Representing a circle by its center and radius.
10. Object Recognition
Assigning labels to objects.
■ Example: Face recognition unlocking your phone.
11. Knowledge Base
Domain knowledge guiding processing.
■ Example: Knowing that medical images have specific intensity ranges.
1.4 Elements of a Digital Image Processing System
A DIP system has hardware and software components working together:
• Image Sensors: Convert physical signal to digital (camera, scanner, MRI machine).
• Digitizer (A/D Converter): Converts analog signal to digital numbers.
• Image Processing Hardware: Special processors for fast computation (GPU).
• Computer: General purpose CPU for processing algorithms.
• Image Storage: Short-term (RAM) and long-term (hard disk, cloud) storage.
• Display: Monitor, printer to show results.
• Hardcopy Device: Printer/plotter for permanent output.
• Network: For transmitting images (telemedicine, internet).
■ Example: A hospital MRI system: The MRI machine (sensor) captures the image → digitizer converts it to
numbers → stored on hospital server → doctor views it on a display monitor.
★ Exam Tip: Draw a simple block diagram: Sensor → Digitizer → Processor → Storage → Display. This is
often asked in 5-mark questions.
SECTION 2: DIGITAL IMAGE FUNDAMENTALS
2.1 Elements of Visual Perception
Understanding how humans see helps us design better image processing algorithms. The human visual
system is our guide!
Structure of the Human Eye:
• Cornea: Transparent outer layer, bends light entering the eye.
• Lens: Focuses light onto the retina (like a camera lens).
• Retina: Inner surface covered with light-sensitive cells (the "film").
• Cones (~6-7 million): Concentrated at center (fovea), detect color and fine detail in bright light.
• Rods (~75-150 million): Spread across retina, detect low light, no color.
• Fovea: Small central area with highest density of cones — sharpest vision here.
• Blind Spot: Where optic nerve exits — no photoreceptors here.
■ Example: Why can you see stars better by looking slightly to the side? Because rods (sensitive to dim
light) are away from the fovea center.
Brightness Adaptation:
The human eye can operate over an enormous range of light intensities — from very dark (starlight) to
very bright (sunlight). This is called brightness adaptation.
• Total range of intensity the eye can handle: 1010 to 1.
• But at any given moment, the eye only adapts to a smaller range.
• Simultaneous contrast: The same gray patch looks different on a black vs white background.
■ Example: When you walk into a dark cinema from bright sunlight, you can't see anything at first. After a
few minutes, your eyes "adapt" to the darkness. This is brightness adaptation!
Mach Band Effect:
Even when intensity changes sharply (a step), the human eye perceives a bright stripe on the light side
and a dark stripe on the dark side of the edge. These illusory stripes are called Mach bands. The eye
enhances edges!
■ Example: Look at a series of gray rectangles from dark to light arranged side by side. At each border, you
will see a slightly brighter band and a slightly darker band that are NOT actually in the image — your visual
system creates them.
■ Note: Mach bands show that the eye performs edge enhancement automatically. This inspires image
sharpening algorithms in DIP.
2.2 A Simple Image Model
A digital image f(x, y) is formed by two components:
f(x, y) = i(x, y) x r(x, y)
• i(x, y) — Illumination component: Amount of light falling on the scene. Range: 0 < i(x, y) < infinity.
Depends on the light source.
• r(x, y) — Reflectance component: Fraction of light reflected by the object. Range: 0 < r(x, y) < 1. (0 =
total absorption like black velvet, 1 = total reflection like mirror)
■ Example: A white paper (r ≈ 0.9) in dim light vs. black cloth (r ≈ 0.01) in bright sunlight: White paper:
i=100, r=0.9 → f = 90 Black cloth: i=1000, r=0.01 → f = 10 So the "dark" cloth in bright light still appears
darker!
■ Note: Typical values: Illumination (i) for indoor lighting ≈ 900 lux, sunlight ≈ 90,000 lux. Reflectance of
snow ≈ 0.93, black velvet ≈ 0.01.
★ Exam Tip: Remember the formula: f(x,y) = i(x,y) × r(x,y). This is frequently asked. Also remember the
ranges of i and r.
2.3 Sampling and Quantization
A real-world image is continuous (analog). To process it on a computer, we must convert it to discrete
digital values. This involves two steps:
Step 1: Sampling (Digitizing the coordinates)
Sampling converts the continuous spatial coordinates (x, y) into a finite grid of points. We choose how
many pixels to use — this is the spatial resolution.
Image size: M rows × N columns More samples (higher M, N) = higher spatial
resolution = sharper image
■ Example: A 640×480 image has 307,200 pixels. A 1920×1080 (Full HD) image has 2,073,600 pixels. The
Full HD image is much sharper because it samples more points from the same scene.
• Nyquist Theorem: Sampling rate must be at least 2× the highest frequency in the image. If sampling is
too low → aliasing (jagged edges, moiré patterns).
■ Example: Staircase effect on diagonal lines in a low-resolution image is aliasing.
Step 2: Quantization (Digitizing the intensity)
Quantization converts the continuous intensity values into a finite set of discrete levels. The number of
levels is determined by the bit depth.
Number of gray levels (L) = 2^k k = number of bits per pixel k=1 → L=2
(binary: black/white) k=4 → L=16 (16 gray levels) k=8 → L=256 (standard
grayscale) k=16→ L=65536 (high precision medical images)
■ Example: An 8-bit grayscale image: each pixel value is 0 (black) to 255 (white). A pixel value of 128 is
medium gray.
• Storage size: M × N × k bits = M × N × k / 8 bytes
■ Example: Storage for 512×512, 8-bit image = 512 × 512 × 8 / 8 = 262,144 bytes ≈ 256 KB
Effect of Reducing Resolution:
• Reducing spatial resolution (fewer pixels) → image becomes blurry/blocky
• Reducing gray levels (fewer bits) → "false contouring" (visible bands of constant gray)
■ Note: False contouring becomes visible when gray levels drop below 32 (5 bits) for smooth images.
★ Exam Tip: Common exam Q: "What is quantization?" Answer: Converting continuous intensity to discrete
levels. Also be ready to calculate storage size from M, N, and k.
2.4 Some Basic Relationships Between Pixels
(a) Neighbours of a Pixel
A pixel p at location (x, y) has different types of neighbours:
• 4-neighbours N4(p): The 4 pixels directly above, below, left, right of p.
• Diagonal neighbours ND(p): The 4 pixels at the diagonal corners of p.
• 8-neighbours N8(p): All 8 surrounding pixels = N4(p) + ND(p).
4-neighbours: (x-1,y), (x+1,y), (x,y-1), (x,y+1) Diagonal: (x-1,y-1),
(x-1,y+1), (x+1,y-1), (x+1,y+1) 8-neighbours: all 8 surrounding pixels
■ Example: For pixel at position (3,3) in an image: 4-neighbours: (2,3), (4,3), (3,2), (3,4) 8-neighbours:
above 4 + (2,2), (2,4), (4,2), (4,4)
(b) Adjacency and Connectivity
Two pixels are adjacent if they are neighbours AND their gray values satisfy some similarity condition
(belong to set V of allowed values).
• 4-adjacency: Two pixels p and q with values in V are 4-adjacent if q is in N4(p).
• 8-adjacency: Two pixels p and q with values in V are 8-adjacent if q is in N8(p).
• m-adjacency (mixed): Combines 4 and diagonal adjacency to eliminate ambiguity.
• Connectivity: A set of pixels S is connected if there is a path between any two pixels in S.
■ Example: Binary image, V = {1}. Two "1" pixels are 4-connected only if they share a horizontal or vertical
edge. This matters when counting separate objects (connected components).
■ Note: m-adjacency was introduced to eliminate the ambiguity that arises with 8-adjacency (multiple paths
at diagonal junctions).
(c) Regions and Boundaries
• Region: A connected subset of pixels in an image.
• Boundary (border): The set of pixels in a region that have at least one neighbour outside the region.
■ Example: In a binary image of a white circle on black background, the boundary is the ring of white pixels
that touch the black background.
(d) Distance Measures
Distance between pixels p(x,y) and q(s,t):
Euclidean distance: De(p,q) = sqrt((x-s)^2 + (y-t)^2) City-block distance:
D4(p,q) = |x-s| + |y-t| Chessboard distance: D8(p,q) = max(|x-s|, |y-t|)
■ Example: Distance between p=(0,0) and q=(2,3): Euclidean: sqrt(4+9) = sqrt(13) ≈ 3.60 City-block (D4):
|2| + |3| = 5 Chessboard (D8): max(2,3) = 3
Distance Type Formula Shape of Equidistant Points Also Called
Euclidean sqrt((x-s)²+(y-t)²) Circle L2 norm
City-block (D4) |x-s|+|y-t| Diamond (rotated square) Manhattan / L1 norm
Chessboard (D8) max(|x-s|,|y-t|) Square L-infinity norm
2.5 Imaging Geometry
Imaging geometry deals with the relationship between a 3D real-world scene and its 2D image captured by
a camera.
Perspective Projection (Pinhole Camera Model):
A pinhole camera projects a 3D point in the world onto a 2D image plane. The mathematical relationship
is:
If a 3D point is at (X, Y, Z) and focal length is f: x_image = f * X / Z
y_image = f * Y / Z
• Focal length (f): Distance from pinhole to image plane.
• Z: Depth (distance from camera to the object).
• Objects farther away appear smaller (divide by larger Z).
■ Example: A building 100m tall at distance 200m from camera (f=10mm): image height = 10 * 100 / 200 = 5
mm Same building at 400m: image height = 10 * 100 / 400 = 2.5 mm — appears half as tall!
Coordinate Systems:
• World coordinates (X, Y, Z): 3D real-world coordinate system.
• Camera coordinates: Centered at the camera/lens.
• Image coordinates (x, y): 2D pixel positions in the image.
• Origin: In DIP, image origin is usually at top-left corner; x goes right, y goes down.
■ Example: The pixel at row 5, column 10 has image coordinates (10, 5) if we use (col, row) notation, or (5,
10) if we use (row, col) notation. Always confirm the convention being used!
■ Note: Imaging geometry is the foundation for 3D reconstruction, stereo vision, and augmented reality
applications.
QUICK REVISION & FORMULA SHEET
Concept Key Formula / Key Fact
Image function f(x,y) = intensity at pixel (x,y)
Image model f(x,y) = i(x,y) × r(x,y); 0<i<∞; 0<r<1
Gray levels L = 2^k; k = bits per pixel
Storage M × N × k bits
4-neighbours (x±1, y) and (x, y±1) — 4 pixels
8-neighbours 4-neighbours + 4 diagonal pixels
Euclidean dist. sqrt((x-s)² + (y-t)²)
City-block (D4) |x-s| + |y-t|
Chessboard (D8) max(|x-s|, |y-t|)
Perspective proj. x = f·X/Z, y = f·Y/Z
Sampling Digitizing spatial coords (x,y) → pixel grid
Quantization Digitizing intensity → discrete gray levels
Nyquist rate Sampling ≥ 2 × highest frequency
Likely Exam Questions (with hints)
2-mark questions:
• Define digital image. → f(x,y), 2D array, pixel.
• What is sampling? → Digitizing spatial coordinates.
• What is quantization? → Digitizing intensity values.
• Define 4-neighbours of a pixel.
• What is the Euclidean distance formula?
5-mark questions:
• Explain the fundamental steps in DIP with examples.
• Explain sampling and quantization with examples.
• Describe the elements of a DIP system with a block diagram.
• Explain the three distance measures between pixels with examples.
• Explain brightness adaptation and Mach bands.
10-mark questions:
• Explain all elements of visual perception. Include structure of the eye, brightness adaptation, and Mach
bands with examples.
• Explain pixel relationships: neighbours, adjacency, connectivity, and distance measures with numerical
examples.
• Explain sampling and quantization in detail. What is the effect of varying M, N and k?
Best of luck for your exam! ■
Remember: Understanding > Memorizing. Use examples in every answer!