IVP Lectures 16-37

Dec 3, 2026
β€’
50 min read
β€’
10554 words

Lecture 16 β€” Interpolation and Resampling


1. Concept of Image Interpolation

  • Discrete Image Grid: A digital image is natively sampled and defined only at discrete integer lattice coordinates: $$f[m, n] \quad \text{for } m, n \in \mathbb{Z}$$
  • Need for Continuous Domain Estimation: In many image processing applicationsβ€”such as zooming (enlargement), shrinking (reduction), rotation, geometric distortion correction, camera calibration, and image registrationβ€”output pixel locations frequently map to non-integer (fractional) continuous coordinates $(x', y')$.
  • Definition of Interpolation: Interpolation is the process of passing a continuous function through discrete sample points to estimate or reconstruct the intensity value $\hat{f}(x', y')$ at any arbitrary non-integer coordinate $(x', y')$ using surrounding known pixel values.

2. Resampling & Image Transformation Pipeline

  • Resampling: The process of generating a new set of discrete intensity samples on a target lattice from an existing sampled digital image.
  • Conceptual Pipeline: $$\text{Original Sampled Grid } f[m, n] \longrightarrow \text{Continuous Surface } \hat{f}(x, y) \longrightarrow \text{New Sampled Grid } g[m', n']$$
  • Forward vs. Inverse Mapping:
    1. Forward Mapping: Maps each original pixel $(x, y)$ to target coordinates $(x', y') = T(x, y)$.
      • Drawback: Can result in “holes” (unassigned destination pixels) or overlap (multiple input pixels mapping to a single output location).
    2. Inverse Mapping: Iterates through each target pixel $(x', y')$, computing its corresponding location in the original image coordinate space: $$(x, y) = T^{-1}(x', y')$$
      • Advantage: Guarantees every target pixel receives an intensity value; uses spatial interpolation at $(x, y)$ to derive the target pixel’s intensity.

3. Geometric Operations: Enlargement & Reduction

  • Enlargement (Zooming):
    • Expands the coordinate grid, increasing pixel density.
    • Generates target points between original grid positions, requiring intensity interpolation.
  • Reduction (Shrinking):
    • Condenses the coordinate grid; multiple original pixels map into a single target pixel region.
    • Aliasing Risk: Direct decimation without prior filtering introduces high-frequency aliasing artifacts.
    • Solution: Pre-filtering with an anti-aliasing low-pass filter prior to sub-sampling.

Lecture 17 β€” Interpolation Techniques

1. Desirable Properties of Interpolation

When interpolating discrete sample values, an interpolation function should satisfy two primary desirable properties:

  1. Finite Region of Support: Interpolation should be computed using local sample information rather than relying on global data across the entire digitized signal.
  2. Smoothness: The interpolation function must be smooth to ensure continuous and visually natural reconstructions.

2. B-Spline Functions & Mathematical Formulation

  • Concept: B-splines enable local approximation of curves using a small number of parameters, making them suitable for smoothing discrete curves and interpolating continuous functions from discrete samples.
  • General B-Spline Equation: An $(n+1)$ sample curve $x(t)$ approximated by control points $p_i$ is represented as: $$x(t) = \sum_{i=0}^{n} p_i B_{i,k}(t)$$ where $p_i$ are the control points (sample values) and $B_{i,k}(t)$ represents the B-spline basis function of order $k$.
  • Recursive Cox-de Boor Relation: The basis function $B_{i,k}(t)$ is computed recursively using: $$B_{i,k}(t) = \left[ \frac{(t - t_i) B_{i,k-1}(t)}{t_{i+k-1} - t_i} \right] + \left[ \frac{(t_{i+1} - 1) B_{i+1,k-1}(t)}{t_{i+k} - t_{i+1}} \right]$$ All translated basis functions $B_{i,k}(t)$ can be obtained directly as spatial shifts of the base function $B_{0,k}(t)$: $$B_{i,k}(t) = B_{0,k}(t - i)$$

3. B-Spline Basis Functions by Order ($k$)

A. Order 1 ($k = 1$): Constant B-Spline

  • Equation: $$B_{0,1}(t) = \begin{cases} 1 & \text{for } 0 \le t < 1 \\ 0 & \text{otherwise} \end{cases}$$
  • Support: Region of support is $1$ unit wide ($0 \le t < 1$). Provides constant piecewise interpolation.

B. Order 2 ($k = 2$): Linear B-Spline

  • Equation: $$B_{0,2}(t) = \begin{cases} t & \text{for } 0 \le t < 1 \\ 2 - t & \text{for } 1 \le t < 2 \\ 0 & \text{otherwise} \end{cases}$$
  • Support: Region of support spans $2$ units (supported across $3$ sample points: $i$, $i+1$, $i+2$). Represents a linear (triangular) function.

C. Order 3 ($k = 3$): Quadratic B-Spline

  • Equation: $$B_{0,3}(t) = \begin{cases} \frac{t^2}{2} & \text{for } 0 \le t < 1 \\ -t^2 + 3t - 1.5 & \text{for } 1 \le t < 2 \\ \frac{(3 - t)^2}{2} & \text{for } 2 \le t < 3 \\ 0 & \text{otherwise} \end{cases}$$
  • Support: Region of support spans $3$ units.

D. Order 4 ($k = 4$): Cubic B-Spline

  • Equation: $$B_{0,4}(t) = \begin{cases} \frac{t^3}{6} & \text{for } 0 \le t < 1 \\ \frac{-3t^3 + 12t^2 - 12t + 4}{6} & \text{for } 1 \le t < 2 \\ \frac{3t^3 - 24t^2 + 60t - 44}{6} & \text{for } 2 \le t < 3 \\ \frac{(4 - t)^3}{6} & \text{for } 3 \le t < 4 \\ 0 & \text{otherwise} \end{cases}$$
  • Support: Region of support spans $4$ units across $5$ sample points. Yields a smooth curve.

4. Symmetric Interpolation & Shifting Parameter ($s$)

  • The Asymmetry Problem: Evaluating unshifted basis functions $B_{i,k}(t)$ directly can assign illogical weights to distant sample points (e.g., evaluating $f(3.1)$ gives more weight to $p_2$ than nearer points).
  • Shifted Formulation: To ensure symmetric weighting around the target interpolation point, a shift parameter $s$ is introduced: $$f(t) = \sum_{i=0}^{n} p_i B_{i-s, k}(t)$$
  • Optimal Shift Values:
    • For $k = 1$ (Constant): $s = 0.5$
    • For $k = 2$ (Linear): $s = 1.0$
    • For $k = 4$ (Cubic): $s = 2.0$
  • Omission of Quadratic Interpolation: Quadratic B-spline interpolation ($k = 3$) naturally leads to asymmetric interpolation and is typically omitted in favor of linear or cubic schemes.

5. Applications in Image Geometric Transformations

A. Image Scaling (Zooming)

  • Without Interpolation: Scaling an image up (e.g., by a factor of 3 in $X$ and $Y$) leaves unassigned pixels, resulting in an incomplete grid of dots.
  • Nearest Neighbor / Constant ($k=1$): Fills all missing pixels but produces sharp blocking artifacts.
  • Quadratic ($k=3$) & Cubic ($k=4$) B-Splines: Produces high-quality, smooth images without blockiness.

B. Image Rotation

  • Without Interpolation: Rotating an image (e.g., by $30^\circ$) creates empty pixel locations that map to black spots/holes.
  • Bicubic Interpolation: Uses cubic B-spline weighting functions to smoothly estimate pixel values and eliminate all black spots.

6. Quiz Solutions (Previous Stereo Imaging Lecture)

Question 1: 3D Point Coordinates from Stereo Pair

Given:

  • Focal length $\lambda = 40\text{ mm}$
  • Left camera coordinate $x_1 = 0.2\text{ mm}$
  • Right camera coordinate $x_2 = 0.4\text{ mm}$
  • Baseline separation $B = 60\text{ mm}$
  1. Depth Computation ($Z$): $$Z = \lambda + \frac{\lambda B}{x_2 - x_1} = 40 + \frac{40 \times 60}{0.4 - 0.2} = 40 + \frac{2400}{0.2} = 12040\text{ mm}$$
  2. $X$ and $Y$ World Coordinates:$$X = \frac{x_1}{\lambda}(\lambda - Z) = \frac{0.2}{40}(40 - 12040) = -60\text{ mm}$$ Applying the same formula yields $Y = -90\text{ mm}$.

Question 2: Minimum Computable Depth for a Stereo System

  • 3D depth can only be computed for points that lie within the overlapping field of view (the conical intersection region) of both cameras.
  • Using the geometry of the imaging plates, camera baseline separation $B$, focal length $\lambda$, and similar triangles, the minimum computable depth corresponds to the apex of this overlap region.

Lecture 18 β€” Interpolation with Examples – I

1. Fundamental Purpose of Signal & Image Interpolation

  • Problem Definition: Given discrete sample values $p_i = f_s(t_i)$ available only at specific grid points $t_0, t_1, t_2, \dots$, image/signal interpolation aims to approximate or reconstruct the continuous function value $f(t)$ at any arbitrary intermediate location $t$ (e.g., $t = 2.3$ or $t = 3.7$).
  • General Interpolation Formula: The continuous function $x(t)$ is reconstructed using a weighted combination of sample values $p_i$ and interpolation basis functions $B_{i,k}(t)$:
$$x(t) = \sum_{i=0}^{n} p_i B_{i,k}(t)$$

2. Three Desirable Properties of Interpolation Functions

To construct a physically meaningful and computationally efficient interpolation function, three core conditions must be satisfied:

  1. Finite Region of Support: Interpolation at a point $t$ should rely strictly on nearby local sample values rather than considering samples across the entire domain from $-\infty$ to $+\infty$.
  2. Smoothness: The interpolation function must exhibit appropriate smoothness and continuity.
  3. Shift Invariance: Shifting the input signal along the domain by a constant displacement (e.g., $t = 5$) must yield the exact same interpolated values across the shifted interval.

3. B-Spline Mathematical Foundations

B-spline basis functions satisfy all three desirable properties. They are defined recursively via the Cox-de Boor formula:

A. Recursive Definition

$$B_{i,k}(t) = \frac{(t - t_i) B_{i,k-1}(t)}{t_{i+k-1} - t_i} + \frac{(t_{i+k} - t) B_{i+1,k-1}(t)}{t_{i+k} - t_{i+1}}$$

where $k$ represents the order of the B-spline basis function.

B. Base Case ($k = 1$, Constant B-Spline)

$$B_{i,1}(t) = \begin{cases} 1 & \text{for } t_i \le t < t_{i+1} \\ 0 & \text{otherwise} \end{cases}$$

For the reference basis function $B_{0,1}(t)$, it equals $1$ for $0 \le t < 1$ and $0$ elsewhere.

C. Shift-Invariance Property

All basis functions for sample index $i$ are simple spatial translations of the reference basis function $B_{0,k}(t)$:

$$B_{i,k}(t) = B_{0,k}(t - i)$$

4. Walkthrough Example 1: Constant B-Spline Interpolation ($k = 1$)

A. Setup

Given discrete sample points at integer locations $t = 0, 1, 2, 3, 4, 5$ with sample values $p_0, p_1, p_2, p_3, p_4, p_5$.

B. Problem: Find the interpolated value $f(1.3)$

Using the interpolation formula for $k = 1$:

$$f(1.3) = p_0 B_{0,1}(1.3) + p_1 B_{1,1}(1.3) + p_2 B_{2,1}(1.3) + \dots$$
  • Evaluating Basis Functions at $t = 1.3$:
    • $B_{0,1}(1.3) = 0$ (since $B_{0,1}(t) = 1$ only for $0 \le t < 1$).
    • $B_{1,1}(1.3) = 1$ (since $B_{1,1}(t) = 1$ for $1 \le t < 2$).
    • $B_{2,1}(1.3) = 0$ (since $B_{2,1}(t) = 1$ for $2 \le t < 3$).
  • Result:
$$f(1.3) = p_0(0) + p_1(1) + p_2(0) = p_1 = f_s(1)$$

C. Interpretation

For any target point $t$ within the interval $1 \le t < 2$, $f(t) = p_1$. Similarly, for $2 \le t < 3$, $f(t) = p_2$, and so on. This produces a piecewise constant (nearest-neighbor style) step function.


5. Walkthrough Example 2: Linear B-Spline Interpolation ($k = 2$)

A. Linear Basis Function Definition

For $k = 2$, $B_{0,2}(t)$ forms a triangular function supported on $[0, 2]$:

$$B_{0,2}(t) = \begin{cases} t & \text{for } 0 \le t < 1 \\ 2 - t & \text{for } 1 \le t < 2 \\ 0 & \text{otherwise} \end{cases}$$

B. Problem: Find the interpolated value $f(1.7)$

Given sample values $p_0 = 0.5$ (at $t = 0$) and $p_1 = 1.0$ (at $t = 1$).

Using the linear formula:

$$f(1.7) = p_0 B_{0,2}(1.7) + p_1 B_{1,2}(1.7) + p_2 B_{2,2}(1.7) + \dots$$
  • Evaluating Basis Functions at $t = 1.7$:
    • $B_{0,2}(1.7) = 2 - 1.7 = 0.3$.
    • $B_{1,2}(1.7) = B_{0,2}(1.7 - 1) = B_{0,2}(0.7) = 0.7$.
    • $B_{2,2}(1.7) = 0$ (since $B_{2,2}(t)$ is supported on $[2, 4]$).
  • Calculation:
$$f(1.7) = p_0 B_{0,2}(1.7) + p_1 B_{0,2}(0.7) = (0.5 \times 0.3) + (1.0 \times 0.7) = 0.15 + 0.70 = 0.85$$

6. Identification of the Asymmetry Problem

  • The Issue: In the linear example above, evaluating $f(1.7)$ (which lies between $t = 1$ and $t = 2$) took contributions from $p_0$ ($t = 0$) and $p_1$ ($t = 1$), completely ignoring $p_2$ ($t = 2$).
  • Cause: Standard unshifted B-spline basis functions $B_{i,k}(t)$ are inherently asymmetric relative to sample intervals.
  • Solution: To achieve symmetric interpolation around target evaluation points, a shift parameter $s$ must be introduced into the interpolation formula:
$$f(t) = \sum_{i=0}^{n} p_i B_{i-s, k}(t)$$

(This sets up the shift-parameter formulation covered in subsequent discussions).


Lecture 19 β€” Interpolation with Examples – II

1. Resolution of the Asymmetry Problem via Shift Parameter ($s$)

A. Motivation for Shifting

  • Standard unshifted B-spline basis functions $B_{i,k}(t)$ are inherently asymmetric relative to sample intervals, causing distant sample points to improperly influence target evaluation points.
  • Solution: To make the region of support symmetric around sample points, a shift parameter $s$ is introduced into the B-spline interpolation formula:
$$f(t) = \sum_{i=0}^{n} p_i B_{i-s, k}(t)$$

This shifts the basis function leftward by $s$ when calculating the contribution of sample $p_i$ to target point $t$.

B. Optimal Shift Values ($s$) by Order ($k$)

  1. Constant Interpolation ($k = 1$): Set $s = 0.5$.
    • The shifted basis function is $B_{i-0.5, 1}(t)$.
    • For sample $p_0$, $B_{-0.5, 1}(t) = 1$ for $-0.5 \le t < 0.5$, and $0$ elsewhere.
  2. Linear Interpolation ($k = 2$): Set $s = 1.0$.
    • The shifted basis function for sample $p_0$ becomes $B_{-1, 2}(t)$.
  3. Cubic Interpolation ($k = 4$): Set $s = 2.0$.
    • The shifted basis function for sample $p_0$ becomes $B_{-2, 4}(t)$.

2. 1D Interpolation & Region of Support Analysis

A. Shifted Constant Interpolation ($k = 1, s = 0.5$)

  • Under $B_{i-0.5, 1}(t)$, each sample value $p_i$ is copied continuously across the symmetric interval $t \in [i - 0.5, i + 0.5)$.
  • Example:
    • For $t \in [-0.5, 0.5)$, $f(t) = p_0$.
    • For $t \in [0.5, 1.5)$, $f(t) = p_1$.
    • For $t \in [1.5, 2.5)$, $f(t) = p_2$.
  • At $t = 2.3$, the products $p_0 B_{-0.5,1}(2.3)$ and $p_1 B_{0.5,1}(2.3)$ evaluate to $0$, leaving only $p_2$ to contribute.

B. Shifted Linear Interpolation ($k = 2, s = 1.0$)

  • Evaluating $f(2.3)$ receives non-zero contributions strictly from the two nearest bounding sample points $p_2$ (at $t = 2$) and $p_3$ (at $t = 3$):
$$f(2.3) = p_2 B_{1,2}(2.3) + p_3 B_{2,2}(2.3)$$

C. Shifted Cubic Interpolation ($k = 4, s = 2.0$)

  • Uses four surrounding sample points $p_{i-1}, p_i, p_{i+1}, p_{i+2}$ for evaluation.
  • For target point $t$, the interpolation equation is:
$$f(t) = \sum_{i=0}^{n} p_i B_{i-2, 4}(t)$$

3. Walkthrough Example: 1D Function Interpolation

Given Sample Values:

  • $f(1) = 1.5$ ($p_1$)
  • $f(2) = 2.5$ ($p_2$)
  • $f(3) = 3.0$ ($p_3$)
  • $f(4) = 2.5$ ($p_4$)
  • $f(5) = 3.0$ ($p_5$)
  • $f(6) = 2.4$ ($p_6$)
  • $f(7) = 1.0$ ($p_7$)
  • $f(8) = 2.5$ ($p_8$)

Objective: Estimate the value $f(4.3)$ using different interpolation methods.

A. Cubic B-Spline Interpolation ($k = 4, s = 2$)

  1. Identify Relevant Samples: For $t = 4.3$, the four participating samples are $f(3), f(4), f(5)$, and $f(6)$.

  2. Formulate Equation:

    $$f(4.3) = f(3) B_{1,4}(4.3) + f(4) B_{2,4}(4.3) + f(5) B_{3,4}(4.3) + f(6) B_{4,4}(4.3)$$
  3. Computed Result: $f(4.3) = 2.7068$.


B. Comparison with Other Methods

  • Nearest-Neighbor / Constant Interpolation:
    • Point $t = 4.3$ is closest to $t = 4$.
    • $f(4.3) \approx f(4) = 2.5$.
  • Linear Interpolation:
    • $f(4.3) = 2.65$.
  • Summary of Results: $$\text{Nearest Neighbor} = 2.50 \quad < \quad \text{Linear} = 2.65 \quad < \quad \text{Cubic} = 2.7068$$

4. Extension to Two-Dimensional (2D) Image Interpolation

A. Grid Coordinate Setup

  • An image is a 2D matrix of discrete sample pixels at integer grid coordinates $(r, c)$.
  • Goal: Find the intensity value at an arbitrary continuous location such as $(4.3, 4.2)$.

B. Separable 1D-to-2D Interpolation Strategy

To evaluate point $(4.3, 4.2)$ enclosed by grid corners $(4,4), (4,5), (5,4),$ and $(5,5)$:

  1. Row-wise Interpolation: Perform 1D interpolation along row $4$ to find value at $(4, 4.2)$, and along row $5$ to find value at $(5, 4.2)$.
  2. Column-wise Interpolation: Perform 1D interpolation along the vertical direction between $(4, 4.2)$ and $(5, 4.2)$ to compute final intensity at $(4.3, 4.2)$.

C. Visual Characteristics in 2D

  • 2D Nearest Neighbor (Constant):
    • Assigns the intensity of the nearest grid pixel to all points within a surrounding square region.
    • Artifacts: Produces prominent blocking artifacts (blocky pixelation).
  • Bilinear & Bicubic Interpolation:
    • Blends surrounding neighboring pixels smoothly, eliminating blocking artifacts and producing continuous transitions.

5. Practical Applications of Image Interpolation

  1. Elimination of Geometric Transformation Artifacts:
    • Fills empty pixel gaps (black patches/holes) caused by image rotation and scaling operations.
  2. Geometric Correction in Satellite Imagery:
    • Satellite sensors capture Earth images during orbital movement and simultaneous Earth rotation.
    • This motion causes sampled ground points to land on irregular non-square grids.
    • 2D interpolation is used to rectify and re-grid satellite images into standard Cartesian coordinates.

Lecture 20 β€” Image Transformation – I

1. Introduction & Motivation for Image Transformations

  • Geometric vs. Image Transformations:
    • Geometric Transformations: Operations such as translation, rotation, and scaling translate coordinates between spatial systems, while perspective transformations map 3D world coordinates onto a 2D imaging plane.
    • Image Transformations: Map an input image of size $N \times N$ into a transformed coefficient matrix of the same size $N \times N$. Applying the inverse transformation recovers the original $N \times N$ image.
  • Primary Applications of Image Transformations:
    1. Preprocessing & Noise Filtering: Noise introduces high-frequency components into an image. In the transform domain, suppressing high-frequency coefficients prior to applying the inverse transform yields a filtered, noise-reduced image.
    2. Image Enhancement: Used to enhance blurry or poor-contrast images by manipulating transform coefficients.
    3. Data Compression: Storing uncompressed black-and-white or color images requires significant memory, and video/image transmission is limited by channel bandwidth. Image transformations concentrate energy into fewer coefficients, forming the foundational step in most image and video compression algorithms.
    4. Feature Extraction: Operates in the transform domain to locate structural features such as edges and corners.

2. Unitary Matrices & Basis Images

  • Definition of a Unitary Matrix: A matrix $A$ is defined as unitary if its inverse $A^{-1}$ equals its complex conjugate transpose $A^{*T}$: $$A^{-1} = A^{*T}$$ where $A^*$ represents the complex conjugate of each element in matrix $A$.
  • Basis Images: The unitary matrices serve as the basis images (or basis functions) used to represent any arbitrary image as a series summation.

3. 1D Continuous Orthogonal & Orthonormal Basis Functions

  • Definition of Orthogonality: A set of real-valued continuous functions $a_n(t) = \{a_0(t), a_1(t), \dots\}$ is orthogonal over an interval $[t_0, t_0 + T]$ if the integral of their product satisfies: $$\int_T a_m(t) a_n(t) \, dt = \begin{cases} k & \text{if } m = n \\ 0 & \text{if } m \neq n \end{cases}$$ where $k$ is a non-zero constant.
  • Orthonormal Set: If the constant $k = 1$, the basis set is defined as orthonormal.
  • Sinusoidal Example: The set $\{\sin \omega t, \sin 2\omega t, \sin 3\omega t, \dots\}$ with fundamental period $T$ (where $\omega = \frac{2\pi}{T}$) forms an orthogonal basis set because the integrated product of any two distinct harmonics over period $T$ equals zero.

4. Derivation of Expansion Coefficients ($C_n$)

  • Series Expansion: An arbitrary continuous signal $x(t)$ can be represented as an infinite series summation: $$x(t) = \sum_{n=0}^{\infty} C_n a_n(t)$$ where $C_n$ represents the $n$-th coefficient of expansion.
  • Mathematical Derivation of $C_m$:
    1. Multiply both sides by $a_m(t)$ and integrate over period $T$: $$\int_T x(t) a_m(t) \, dt = \int_T \left[ \sum_{n=0}^{\infty} C_n a_n(t) \right] a_m(t) \, dt$$
    2. Applying orthogonality ($\int_T a_n(t) a_m(t) \, dt = 0$ for $n \neq m$) reduces all terms on the right-hand side to zero except when $n = m$: $$\int_T x(t) a_m(t) \, dt = C_m \int_T a_m^2(t) \, dt = k C_m$$
    3. Solving for the $m$-th coefficient $C_m$: $$C_m = \frac{1}{k} \int_T x(t) a_m(t) \, dt$$
    4. For an orthonormal set ($k = 1$), this simplifies directly to: $$C_m = \int_T x(t) a_m(t) \, dt$$

5. Completeness of Orthogonal Basis Functions

A set of orthogonal basis functions $a_n(t)$ is defined as complete (or closed) if either of the following conditions holds:

  1. There exists no finite-energy signal $x(t)$ (satisfying $\int_T x^2(t) \, dt < \infty$) such that $\int_T x(t) a_n(t) \, dt = 0$ for all $n$.
  2. For any piecewise continuous finite-energy signal $x(t)$, there exists an arbitrary small $\epsilon > 0$ and a finite number of terms $N$ such that the truncated expansion $\hat{x}(t) = \sum_{n=0}^{N-1} C_n a_n(t)$ bounds the integrated error energy: $$\int_T |x(t) - \hat{x}(t)|^2 \, dt < \epsilon$$

Lecture 21 β€” Image Transformation – II

1. Discrete 1D Signal Transformation

  • Vector Form: A 1D discrete sequence of $N$ samples $u(n)$ (for $0 \le n \le N-1$) is represented as an $N$-dimensional vector $\mathbf{u}$.
  • Forward 1D Transformation: Pre-multiplying vector $\mathbf{u}$ by an $N \times N$ unitary matrix $A$ yields transformed vector $\mathbf{v}$: $$\mathbf{v} = A \mathbf{u}$$ In series summation form for each element $v(k)$: $$v(k) = \sum_{n=0}^{N-1} a(k, n) u(n) \quad \text{for } k = 0, 1, \dots, N-1$$
  • Inverse 1D Transformation: Pre-multiplying vector $\mathbf{v}$ by $A^{-1} = A^{*T}$ recovers vector $\mathbf{u}$: $$\mathbf{u} = A^{*T} \mathbf{v}$$ In series summation form: $$u(n) = \sum_{k=0}^{N-1} a^*(k, n) v(k) \quad \text{for } n = 0, 1, \dots, N-1$$ where $a^*(k, n)$ represents the column vectors of matrix $A^{*T}$, which serve as the basis vectors of matrix $A$.

2. Extension to 2D Image Transformation

  • 2D Image Representation: A 2D image is represented as an $N \times N$ matrix $u(m, n)$, where $0 \le m, n \le N-1$.
  • Forward 2D Transformation: The transform coefficient matrix $v(k, l)$ is computed as: $$v(k, l) = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} a_{k,l}(m, n) u(m, n) \quad \text{for } 0 \le k, l \le N-1$$ where $a_{k,l}(m, n)$ represents the $N^2$ transformation kernel matrices.
  • Inverse 2D Transformation: The original image matrix $u(m, n)$ is reconstructed as a series summation of $N^2$ basis images $a^*_{k,l}(m, n)$ weighted by coefficients $v(k, l)$: $$u(m, n) = \sum_{k=0}^{N-1} \sum_{l=0}^{N-1} a^*_{k,l}(m, n) v(k, l)$$

3. Matrix Orthogonality and Completeness Conditions

  • Orthogonality Property: $$\sum_{k=0}^{N-1} \sum_{l=0}^{N-1} a_{k,l}(m, n) a^*_{k,l}(m', n') = \delta(m - m', n - n')$$ where $\delta$ is the Kronecker delta function (equals $1$ when $m = m'$ and $n = n'$, and $0$ otherwise).
  • Completeness Property: $$\sum_{m=0}^{N-1} \sum_{n=0}^{N-1} a_{k,l}(m, n) a^*_{k',l'}(m, n) = \delta(k - k', l - l')$$

4. Image Approximation, Truncation, and Error

  • Truncated Image Reconstruction: Instead of utilizing all $N^2$ coefficients, an approximate reconstructed image $\hat{u}(m, n)$ can be formed using a reduced subset of $P \times Q$ coefficients ($0 \le k \le P-1$ and $0 \le l \le Q-1$): $$\hat{u}(m, n) = \sum_{k=0}^{P-1} \sum_{l=0}^{Q-1} a^*_{k,l}(m, n) v(k, l)$$
  • Sum of Squared Error (SSE): The approximation error introduced by truncation is given by: $$\epsilon^2 = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} [u(m, n) - \hat{u}(m, n)]^2$$ This error is minimized when the set of basis images $a_{k,l}(m, n)$ forms a complete basis set.

5. Computational Complexity

  • Direct Computation Cost: Calculating the 2D forward or inverse transform for an $N \times N$ image directly requires $O(N^4)$ arithmetic operations.
  • Need for Fast Algorithms: Due to this heavy computational requirement, practical implementations rely on separable basis kernels to reduce computational complexity.

Lecture 22 β€” Separable Transformation


1. 1D Unitary Transformation Foundations

  • Forward 1D Transform: $\mathbf{v} = A \mathbf{u} \implies v(k) = \sum_{n=0}^{N-1} a(k, n) u(n)$.
  • Unitary Condition: Matrix $A$ is unitary if $A^{-1} = A^{*T}$, which implies $A A^{*T} = A^{*T} A = I$.
  • Inverse 1D Transform: $\mathbf{u} = A^{*T} \mathbf{v} \implies u(n) = \sum_{k=0}^{N-1} v(k) a^*(k, n)$.

2. 2D Direct Transformation & Computational Complexity

  • Direct 2D Forward Transform: $$v(k,l) = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} u(m,n) a_{k,l}(m,n)$$
  • Computational Cost:
    • Computing a single coefficient $v(k,l)$ requires $O(N^2)$ complex multiplications and additions.
    • Computing all $N^2$ coefficients requires $O(N^4)$ total operations.
    • For standard image sizes ($256 \times 256$, $512 \times 512$, $1024 \times 1024$), $O(N^4)$ complexity is computationally prohibitive.

3. Separable Unitary Transform Formulation

  • Separability Condition: A transformation kernel $a_{k,l}(m,n)$ is defined as separable if it can be factored into a product of two 1D basis functions: $$a_{k,l}(m,n) = a_k(m) b_l(n)$$
  • When $a_k(m)$ and $b_l(n)$ stem from the same unitary transformation matrix $A$: $$a_{k,l}(m,n) = a(k,m) a(l,n)$$
  • Series Form: $$v(k,l) = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} a(k,m) u(m,n) a(l,n)$$
  • Matrix Form: $$V = A U A^T$$
  • Inverse Separable Transformation: $$U = A^{*T} V A^*$$

4. Two-Pass Execution & Complexity Reduction

A. Matrix Factorization Strategy

The separable transformation $V = A U A^T$ can be rewritten in transposed form:

$$V^T = A [A U]^T$$

This expresses the 2D transform as a two-pass sequence of 1D operations:

  1. Pass 1 (Column Transformation): Compute $A U$ by multiplying matrix $A$ with each column of the input image $U$.
  2. Pass 2 (Row Transformation): Transpose the intermediate result and pre-multiply by matrix $A$ to transform each row.

B. Computational Complexity Reduction

  • Pass 1 Complexity: Multiplying two $N \times N$ matrices ($A$ and $U$) requires $O(N^3)$ operations.
  • Pass 2 Complexity: Multiplying matrix $A$ by $[A U]^T$ requires $O(N^3)$ operations.
  • Total Separable Complexity: $$\text{Total Operations} = O(N^3) + O(N^3) = O(2 N^3) \approx O(N^3)$$
  • Efficiency Gain: Factoring a 2D transform into separable 1D transforms reduces computational complexity by a factor of $N$ (from $O(N^4)$ down to $O(N^3)$).

Lecture 23 β€” Basis Images


1. Mathematical Concept & Definition of Basis Images

  • Transformation Matrix Column Vectors: Let $a_k^*$ denote the $k$-th column of the matrix $A^{*T}$, where $A$ is an $N \times N$ unitary transformation matrix.
  • Definition of Basis Matrix/Image ($A_{k,l}^*$): The $(k, l)$-th basis image matrix $A_{k,l}^*$ is formed by taking the outer product of column vectors $a_k^*$ and $a_l^*$: $$A_{k,l}^* = a_k^* a_l^{*T} \quad \text{for } k, l = 0, 1, \dots, N-1$$ Since indices $k$ and $l$ both range from $0$ to $N-1$, there are $N^2$ unique basis image matrices $A_{k,l}^*$, each of dimension $N \times N$.

2. Matrix Inner Product & Transform Projections

  • Matrix Inner Product Definition: The inner product of two $N \times N$ matrices $F$ and $G$ is defined as:

    $$\langle F, G \rangle = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} f(m,n) g^*(m,n)$$
  • Forward Transform as an Inner Product: The forward transformation coefficient $v(k,l)$ represents the inner product (or projection) of the input image matrix $U$ onto the $(k, l)$-th basis image $A_{k,l}^*$:

    $$v(k,l) = \sum_{m=0}^{N-1} \sum_{n=0}^{N-1} u(m,n) a_{k,l}(m,n) = \langle U, A_{k,l}^* \rangle$$
  • Inverse Transformation & Series Expansion: The original image $U$ is reconstructed as a linear combination of all $N^2$ basis images weighted by their respective transform coefficients $v(k,l)$:

    $$u(m,n) = \sum_{k=0}^{N-1} \sum_{l=0}^{N-1} v(k,l) a_{k,l}^*(m,n) \implies U = \sum_{k=0}^{N-1} \sum_{l=0}^{N-1} v(k,l) A_{k,l}^*$$
    • Core Objective: The primary purpose of image transformation is to decompose an arbitrary input image into a complete set of $N^2$ basis images.

3. Structural Examples of Basis Images

  • Discrete Fourier Transform (DFT): Has two basis image components per index pairβ€”one representing the real part and one representing the imaginary part.
  • Discrete Cosine Transform (DCT), Walsh, and Hadamard Transforms: Produce distinct spatial pattern matrices (e.g., $8 \times 8 = 64$ basis images for an $8 \times 8$ image block).

4. Complete Walkthrough Example ($2 \times 2$ Image Matrix)

A. Given Input Data

  • Transformation Matrix ($A$): $$A = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$$
  • Input Image Matrix ($U$): $$U = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$$

B. Computation of Transform Coefficients Matrix ($V$)

Using the separable matrix transform $V = A U A^T$ (where $A^T = A$):

$$A U = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \frac{1}{\sqrt{2}} \begin{bmatrix} 4 & 6 \\ -2 & -2 \end{bmatrix}$$ $$V = A U A^T = \frac{1}{2} \begin{bmatrix} 4 & 6 \\ -2 & -2 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \frac{1}{2} \begin{bmatrix} 10 & -2 \\ -4 & 0 \end{bmatrix} = \begin{bmatrix} 5 & -1 \\ -2 & 0 \end{bmatrix}$$

C. Construction of the 4 Basis Images ($A_{k,l}^*$)

The column vectors of $A^{*T}$ are $a_0^* = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ 1 \end{bmatrix}$ and $a_1^* = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ -1 \end{bmatrix}$:

  • $A_{0,0}^*$: $$A_{0,0}^* = a_0^* a_0^{*T} = \frac{1}{2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \end{bmatrix} = \frac{1}{2} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}$$
  • $A_{0,1}^*$: $$A_{0,1}^* = a_0^* a_1^{*T} = \frac{1}{2} \begin{bmatrix} 1 \\ 1 \end{bmatrix} \begin{bmatrix} 1 & -1 \end{bmatrix} = \frac{1}{2} \begin{bmatrix} 1 & -1 \\ 1 & -1 \end{bmatrix}$$
  • $A_{1,0}^*$: $$A_{1,0}^* = a_1^* a_0^{*T} = \frac{1}{2} \begin{bmatrix} 1 \\ -1 \end{bmatrix} \begin{bmatrix} 1 & 1 \end{bmatrix} = \frac{1}{2} \begin{bmatrix} 1 & 1 \\ -1 & -1 \end{bmatrix}$$
  • $A_{1,1}^*$: $$A_{1,1}^* = a_1^* a_1^{*T} = \frac{1}{2} \begin{bmatrix} 1 \\ -1 \end{bmatrix} \begin{bmatrix} 1 & -1 \end{bmatrix} = \frac{1}{2} \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$

D. Verification via Inverse Transformation

Applying $U = A^{*T} V A^*$:

$$U = \frac{1}{2} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \begin{bmatrix} 5 & -1 \\ -2 & 0 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$$

The original input image $U$ is recovered exactly.


5. Vectorization & Kronecker Product Representation

  • Row-Ordering Vectorization: Concatenating rows of an $N \times N$ image matrix $U$ forms an $N^2 \times 1$ vector $\mathbf{u}$. Similarly, $V$ maps to vector $\mathbf{v}$.
  • Kronecker Product ($\otimes$) Formulation: The 2D transformation converts into a 1D vector matrix operation using the Kronecker product $\mathcal{A} = A \otimes A$: $$\mathbf{v} = (A \otimes A) \mathbf{u} = \mathcal{A} \mathbf{u}$$ $$\mathbf{u} = (A \otimes A)^{*T} \mathbf{v} = \mathcal{A}^{*T} \mathbf{v}$$
  • Separability Condition: A transformation matrix $\mathcal{A}$ is separable if it can be represented as the Kronecker product of two smaller matrices: $\mathcal{A} = A_1 \otimes A_2$. In matrix form: $$Y = A_1 X A_2^T$$

Lecture 24 β€” Fourier Transformation


1. Continuous Fourier Transform

A. 1D Continuous Fourier Transform

  • Forward Transform: $$F(u) = \int_{-\infty}^{\infty} f(x) e^{-j 2 \pi u x} \, dx$$
  • Inverse Transform: $$f(x) = \int_{-\infty}^{\infty} F(u) e^{j 2 \pi u x} \, du$$
  • Requirements: Function $f(x)$ must be continuous and integrable. The variable $u$ represents spatial frequency. $F(u)$ and $f(x)$ form a Fourier transform pair.

B. Complex Spectrum, Phase Angle, and Power Spectrum

Because $e^{-j 2 \pi u x}$ is complex, $F(u)$ decomposes into real and imaginary parts: $F(u) = R(u) + j I(u)$.

  • Fourier Spectrum (Magnitude): $$|F(u)| = \sqrt{R^2(u) + I^2(u)}$$
  • Phase Angle ($\phi(u)$): $$\phi(u) = \tan^{-1} \left( \frac{I(u)}{R(u)} \right)$$
  • Power Spectrum ($P(u)$): $$P(u) = |F(u)|^2 = R^2(u) + I^2(u)$$

C. 2D Continuous Fourier Transform

  • Forward Transform: $$F(u, v) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} f(x, y) e^{-j 2 \pi (u x + v y)} \, dx \, dy$$
  • Inverse Transform: $$f(x, y) = \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} F(u, v) e^{j 2 \pi (u x + v y)} \, du \, dv$$
  • 2D Spectrum & Phase: $$|F(u, v)| = \sqrt{R^2(u, v) + I^2(u, v)}, \quad \phi(u, v) = \tan^{-1} \left( \frac{I(u, v)}{R(u, v)} \right)$$

D. Worked Example: 2D Rectangular Continuous Function

Given a 2D rectangular pulse function $f(x, y) = A$ for $0 \le x \le X$ and $0 \le y \le Y$, and $0$ elsewhere:

$$F(u, v) = \int_0^X \int_0^Y A e^{-j 2 \pi (u x + v y)} \, dy \, dx = A \left( \int_0^X e^{-j 2 \pi u x} \, dx \right) \left( \int_0^Y e^{-j 2 \pi v y} \, dy \right)$$ $$F(u, v) = A X Y \left[ \frac{\sin(\pi u X)}{\pi u X} e^{-j \pi u X} \right] \left[ \frac{\sin(\pi v Y)}{\pi v Y} e^{-j \pi v Y} \right]$$
  • Fourier Spectrum: $$|F(u, v)| = A X Y \left| \frac{\sin(\pi u X)}{\pi u X} \right| \left| \frac{\sin(\pi v Y)}{\pi v Y} \right|$$ Zeros of the spectrum occur along the frequency axes at integer multiples: $u = \frac{1}{X}, \frac{2}{X}, \dots$ and $v = \frac{1}{Y}, \frac{2}{Y}, \dots$.

2. Discrete Fourier Transform (DFT)

A. General $M \times N$ Discrete Image

  • Forward DFT: $$F(u, v) = \frac{1}{M N} \sum_{x=0}^{M-1} \sum_{y=0}^{N-1} f(x, y) e^{-j 2 \pi \left( \frac{u x}{M} + \frac{v y}{N} \right)}$$ for $u = 0, 1, \dots, M-1$ and $v = 0, 1, \dots, N-1$.
  • Inverse DFT: $$f(x, y) = \sum_{u=0}^{M-1} \sum_{v=0}^{N-1} F(u, v) e^{j 2 \pi \left( \frac{u x}{M} + \frac{v y}{N} \right)}$$

B. Square $N \times N$ Discrete Image

  • Forward DFT: $$F(u, v) = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x, y) e^{-j \frac{2 \pi}{N} (u x + v y)}$$
  • Inverse DFT: $$f(x, y) = \frac{1}{N} \sum_{u=0}^{N-1} \sum_{v=0}^{N-1} F(u, v) e^{j \frac{2 \pi}{N} (u x + v y)}$$

C. Spectral Characteristics & The DC Component

  • Basis Functions: Complex exponentials $e^{j \frac{2\pi}{N}(ux + vy)}$ separate into real and imaginary basis images.
  • DC Component at Origin: In natural images (e.g., Lena image), maximum spectral energy is centered at the origin $(u=0, v=0)$. This origin coefficient represents the DC component (average brightness) of the image. Energy decreases significantly at higher spatial frequencies.

Lecture 25 β€” FT Result Display - 2

1. Recap of Previous Properties

A. Separability Property

  • The 2D Discrete Fourier Transform (DFT) for an $N \times N$ discrete image $f(x,y)$ is separable and can be expressed as: $$F(u,v) = \frac{1}{N} \sum_{x=0}^{N-1} \left( \sum_{y=0}^{N-1} f(x,y) e^{-j \frac{2\pi}{N} vy} \right) e^{-j \frac{2\pi}{N} ux}$$
  • Implementation: Computes 2D DFT in two sequential 1D passes:
    1. Row Transformation: Compute 1D DFT for every individual row of $f(x,y)$ and multiply by $N$, producing intermediate array $F(x,v)$.
    2. Column Transformation: Compute 1D DFT for every column of $F(x,v)$ to obtain final 2D frequency spectrum $F(u,v)$.
  • The Inverse Discrete Fourier Transform (IDFT) is also separable and follows the same two-pass row-column sequence.

B. Translation Property

  • Spatial Shift: Translating an image by $(x_0, y_0)$ introduces a linear phase shift in the frequency domain without altering the magnitude spectrum: $$f(x - x_0, y - y_0) \iff F(u,v) e^{-j \frac{2\pi}{N} (u x_0 + v y_0)}$$ $$|F_t(u,v)| = |F(u,v)|$$
  • Frequency Shift: Multiplying an image by a complex exponential shifts its Fourier spectrum in the frequency domain by $(u_0, v_0)$: $$f(x,y) e^{j \frac{2\pi}{N} (u_0 x + v_0 y)} \iff F(u - u_0, v - v_0)$$

2. Periodicity Property

  • Definition: Both the DFT and IDFT are periodic in both frequency axes with period $N$:

    $$F(u,v) = F(u+N, v) = F(u, v+N) = F(u+N, v+N)$$
  • Mathematical Proof: Substituting $u + N$ and $v + N$ into the DFT formulation:

    $$F(u+N, v+N) = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x,y) e^{-j \frac{2\pi}{N} (ux + vy + Nx + Ny)}$$ $$F(u+N, v+N) = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x,y) e^{-j \frac{2\pi}{N} (ux + vy)} \cdot e^{-j 2\pi (x + y)}$$

    Since $x$ and $y$ are integers, $x + y$ is an integer, making $e^{-j 2\pi (x+y)} = 1$. Therefore:

    $$F(u+N, v+N) = F(u,v)$$

3. Conjugate Symmetry Property

  • Definition: If the spatial image $f(x,y)$ is real-valued, its Fourier transform exhibits conjugate symmetry about the origin: $$F(u,v) = F^*(-u, -v)$$ where $F^*$ denotes the complex conjugate.
  • Magnitude Symmetry: Taking the absolute value yields an even magnitude spectrum: $$|F(u,v)| = |F(-u, -v)|$$

4. Spectrum Display & Centering Property

  • Unshifted Spectrum Issue: Because $F(u)$ is periodic with period $N$ and $|F(u)| = |F(-u)|$, evaluating DFT directly over $u \in [0, N-1]$ produces two back-to-back half periods split across the boundaries rather than a unified centered spectrum.

    • The transform values from $N/2 + 1$ to $N-1$ are reflections of the negative frequency half-period to the left of the origin.
  • Centering Method (Origin Shift by $N/2$): To display the spectrum with the low-frequency DC component centered at $(N/2, N/2)$ (or $N/2$ in 1D), shift the frequency origin by $N/2$.

    • Procedure: Pre-multiply spatial signal $f(x,y)$ by $(-1)^{x+y}$ (or $(-1)^x$ in 1D) prior to computing the DFT: $$f(x,y) (-1)^{x+y} \iff F\left(u - \frac{N}{2}, v - \frac{N}{2}\right)$$
    • Derivation: Derived directly from the frequency translation property with $u_0 = v_0 = N/2$, since $e^{j \frac{2\pi}{N} \left( \frac{N}{2} x + \frac{N}{2} y \right)} = e^{j \pi (x + y)} = (-1)^{x+y}$.

Lecture 26 β€” Rotation Invariance & General DFT Properties


1. Rotation Invariance Property

  • Polar Coordinates Formulation: Convert spatial coordinates $(x, y)$ and frequency coordinates $(u, v)$ to polar form:

    $$x = r \cos\theta, \quad y = r \sin\theta$$ $$u = \omega \cos\phi, \quad v = \omega \sin\phi$$

    This transforms $f(x,y) \to f(r, \theta)$ and $F(u,v) \to F(\omega, \phi)$.

  • Rotation Property: Rotating the spatial image $f(r, \theta)$ by an angle $\theta_0$ rotates its 2D Fourier transform in the frequency domain by the exact same angle $\theta_0$:

    $$f(r, \theta + \theta_0) \iff F(\omega, \phi + \theta_0)$$
  • Visual Illustration: Rotating a binary rectangle image by $45^\circ$ causes its corresponding 2D Fourier magnitude spectrum to rotate by $45^\circ$.


2. Distributivity Property

  • Addition: The DFT and IDFT are distributive over addition: $$\mathcal{F}\{f_1(x,y) + f_2(x,y)\} = F_1(u,v) + F_2(u,v)$$
  • Multiplication: The DFT and IDFT are not distributive over multiplication: $$\mathcal{F}\{f_1(x,y) \cdot f_2(x,y)\} \neq F_1(u,v) \cdot F_2(u,v)$$

3. Scaling Property

  • Scalar Multiplication: $$a \cdot f(x,y) \iff a \cdot F(u,v)$$
  • Spatial Coordinate Scaling: Scaling the spatial dimensions $(x, y)$ by scalars $(a, b)$ inversely scales the frequency dimensions $(u, v)$ and scales the magnitude by $\frac{1}{|ab|}$: $$f(ax, by) \iff \frac{1}{|ab|} F\left(\frac{u}{a}, \frac{v}{b}\right)$$

4. Average Value & The DC Component

  • Average Value ($\bar{f}$): $$\bar{f} = \frac{1}{N^2} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x,y)$$
  • Zero Frequency Coefficient ($F(0,0)$): Evaluating the DFT at $u=0, v=0$ gives: $$F(0,0) = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x,y)$$
  • Relationship: The average value of the spatial signal equals the DC component divided by $N$: $$\bar{f} = \frac{1}{N} F(0,0)$$

5. Convolution & Correlation Properties

A. Convolution Property

  • Spatial domain convolution corresponds to frequency domain multiplication: $$f(x,y) * g(x,y) \iff F(u,v) \cdot G(u,v)$$
  • Spatial domain multiplication corresponds to frequency domain convolution: $$f(x,y) \cdot g(x,y) \iff F(u,v) * G(u,v)$$

B. Correlation Property

  • Spatial domain cross-correlation corresponds to multiplication by the complex conjugate in the frequency domain: $$f(x,y) \circ g(x,y) \iff F^*(u,v) \cdot G(u,v)$$
  • Spatial multiplication by complex conjugate corresponds to frequency domain correlation: $$f^*(x,y) \cdot g(x,y) \iff F(u,v) \circ G(u,v)$$

6. Fast Fourier Transform (FFT) Algorithm

A. Computational Motivation

  • Direct computation of 2D DFT requires $O(N^4)$ complex operations.
  • Direct computation of 1D DFT requires $O(N^2)$ complex operations.
  • Using separability reduces 2D DFT to $O(N^3)$ operations, but $O(N^2)$ per 1D pass remains computationally expensive for large data sizes.

B. Radix-2 Decimation-in-Time Decomposition

Assuming total sample size $N = 2^M$ (where $M = \log_2 N$):

  • Introduce kernel notation $W_N = e^{-j \frac{2\pi}{N}}$: $$F(u) = \frac{1}{N} \sum_{x=0}^{N-1} f(x) W_N^{ux}$$
  • Split the $N$-point sequence into even-indexed samples $f(2x)$ and odd-indexed samples $f(2x+1)$ for $x = 0, 1, \dots, \frac{N}{2}-1$: $$F(u) = \frac{1}{2} \left[ \frac{1}{M} \sum_{x=0}^{M-1} f(2x) W_M^{ux} + \frac{1}{M} \sum_{x=0}^{M-1} f(2x+1) W_M^{ux} W_{2M}^u \right]$$ where $M = N/2$.

C. Even/Odd Butterfly Recombination

  • First Half ($u = 0, 1, \dots, \frac{N}{2}-1$): $$F(u) = \frac{1}{2} \left[ F_{\text{even}}(u) + F_{\text{odd}}(u) W_N^u \right]$$
  • Second Half ($u = \frac{N}{2}, \dots, N-1$): Using $W_N^{u + N/2} = -W_N^u$: $$F\left(u + \frac{N}{2}\right) = \frac{1}{2} \left[ F_{\text{even}}(u) - F_{\text{odd}}(u) W_N^u \right]$$

D. Computational Complexity Reduction

  • Splitting an $N$-point DFT into two $(N/2)$-point DFTs reduces operations from $N^2$ down to $2 \left(\frac{N}{2}\right)^2 = \frac{N^2}{2}$ (a $2\times$ speedup).
  • Recursively subdividing down to 2-point DFTs yields the Fast Fourier Transform (FFT) algorithm.
  • Final Complexity: $$\text{FFT Complexity} = O(N \log_2 N)$$ This represents an immense reduction compared to direct $O(N^2)$ computation.

Lecture 27 β€” Rotation Invariance Property

The Fourier transform has a particularly important geometric property:

Rotation in the spatial domain produces the same rotation in the frequency domain.

If:

$$ g(x,y) $$

is a rotated version of:

$$ f(x,y), $$

then its Fourier spectrum is rotated by the same angle.


1. Magnitude invariance to translation

Translation changes the phase but not the magnitude:

$$ |G(u,v)|=|F(u,v)|. $$

Therefore the Fourier magnitude is translation invariant.


2. Rotation relationship

If the image is rotated by:

$$ \theta, $$

the Fourier magnitude is also rotated by:

$$ \theta. $$

Therefore rotation can be detected or normalized in the frequency domain.


3. Why this matters

This property is useful in:

  • pattern recognition,
  • image registration,
  • object matching,
  • invariant feature construction.

A transformed representation can therefore make geometric relationships easier to analyze.


Lecture 28 β€” DCT and Walsh Transform


1. Class of Separable & Symmetric Transformations

Before analyzing specific transforms, 2D image transformations build upon a general mathematical framework.

A. General 2D Image Transformation

For an $N \times N$ 2D image $f(x, y)$ where $x, y \in [0, N-1]$, the forward transformation $T(u, v)$ and inverse transformation $f(x, y)$ are defined as:

$$T(u, v) = \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x, y) g(x, y, u, v)$$ $$f(x, y) = \sum_{u=0}^{N-1} \sum_{v=0}^{N-1} T(u, v) h(x, y, u, v)$$

where $g(x, y, u, v)$ is the forward transformation kernel and $h(x, y, u, v)$ is the inverse transformation kernel.

B. Separability & Symmetry

  • Separable Kernel: A transformation kernel $g(x, y, u, v)$ is separable if it can be factored into two 1D kernels: $$g(x, y, u, v) = g_1(x, u) g_2(y, v)$$
  • Symmetric Kernel: A separable kernel is symmetric if $g_1$ and $g_2$ are functionally identical: $$g(x, y, u, v) = g_1(x, u) g_1(y, v)$$
  • Example (2D DFT): The Discrete Fourier Transform forward kernel $g(x, y, u, v) = \frac{1}{N} e^{-j \frac{2\pi}{N} (ux + vy)} = \left(\frac{1}{\sqrt{N}} e^{-j \frac{2\pi}{N} ux}\right) \left(\frac{1}{\sqrt{N}} e^{-j \frac{2\pi}{N} vy}\right)$ is both separable and symmetric.

2. Discrete Cosine Transform (DCT)

A. Forward and Inverse Kernels

In DCT, the forward kernel $g(x, y, u, v)$ and inverse kernel $h(x, y, u, v)$ are identical, separable, and symmetric:

$$g(x, y, u, v) = h(x, y, u, v) = \alpha(u) \alpha(v) \cos \left[ \frac{(2x + 1) u \pi}{2N} \right] \cos \left[ \frac{(2y + 1) v \pi}{2N} \right]$$

Where the normalization scaling factors $\alpha(u)$ and $\alpha(v)$ are defined as:

$$\alpha(u) = \begin{cases} \sqrt{\frac{1}{N}} & \text{for } u = 0 \\ \sqrt{\frac{2}{N}} & \text{for } u = 1, 2, \dots, N-1 \end{cases}$$

B. Forward and Inverse 2D DCT Expressions

  • Forward 2D DCT:

    $$C(u, v) = \alpha(u) \alpha(v) \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x, y) \cos \left[ \frac{(2x + 1) u \pi}{2N} \right] \cos \left[ \frac{(2y + 1) v \pi}{2N} \right]$$

    (Note: $\alpha(u) \alpha(v)$ is placed outside the double summation because the summation is over $x$ and $y$).

  • Inverse 2D DCT:

    $$f(x, y) = \sum_{u=0}^{N-1} \sum_{v=0}^{N-1} \alpha(u) \alpha(v) C(u, v) \cos \left[ \frac{(2x + 1) u \pi}{2N} \right] \cos \left[ \frac{(2y + 1) v \pi}{2N} \right]$$

    (Note: $\alpha(u) \alpha(v)$ is kept inside the double summation because the summation is over $u$ and $v$).

C. Key Properties of DCT

  • Energy Compaction Property: Signal/image energy is concentrated in a small region near the origin $(0, 0)$ in the frequency domain. This makes DCT effective for image data compression.
  • Periodicity ($2N$): Unlike DFT (which is periodic with period $N$), the magnitude of DCT coefficients is periodic with period $2N$. This $2N$ periodicity avoids boundary jump discontinuities during block-based compression, yielding smoother reconstructed data.
  • Fast Algorithm: Implemented efficiently via Fast DCT (FDCT) algorithms.

3. Discrete Walsh Transform

A. 1D Walsh Transform Formulations

  • 1D Forward Kernel: $$g(x, u) = \frac{1}{N} \prod_{i=0}^{n-1} (-1)^{b_i(x) b_{n-1-i}(u)}$$ where $N$ is the number of samples, $n = \log_2 N$ is the number of bits required to represent $x$ and $u$, and $b_k(z)$ denotes the $k$-th bit in the binary representation of integer $z$.
  • 1D Forward Walsh Transform: $$W(u) = \frac{1}{N} \sum_{x=0}^{N-1} f(x) \prod_{i=0}^{n-1} (-1)^{b_i(x) b_{n-1-i}(u)}$$
  • 1D Inverse Walsh Transform: $$f(x) = \sum_{u=0}^{N-1} W(u) \prod_{i=0}^{n-1} (-1)^{b_i(x) b_{n-1-i}(u)}$$ (Forward and inverse operations are identical, differing only by the multiplicative factor $\frac{1}{N}$).

B. 2D Walsh Transform Formulations

  • 2D Forward Kernel: $$g(x, y, u, v) = \frac{1}{N} \prod_{i=0}^{n-1} (-1)^{b_i(x) b_{n-1-i}(u) + b_i(y) b_{n-1-i}(v)}$$
  • 2D Forward Walsh Transform: $$W(u, v) = \frac{1}{N} \sum_{x=0}^{N-1} \sum_{y=0}^{N-1} f(x, y) \prod_{i=0}^{n-1} (-1)^{b_i(x) b_{n-1-i}(u) + b_i(y) b_{n-1-i}(v)}$$

C. Properties & Fast Implementation

  • Separable & Symmetric: Can be computed using 1D row-wise operations followed by 1D column-wise operations.
  • Fast Walsh Transform (FWT): Samples are recursively split into even and odd groups: $$W(u) = \frac{1}{2} \left[ W_{\text{even}}(u) + W_{\text{odd}}(u) \right] \quad \text{for } u = 0, 1, \dots, \frac{N}{2} - 1$$
  • Energy Compaction: Displays energy compaction near the origin, but it is weaker than DCT.

Lecture 29 β€” Hadamard Transformation


1. 1D & 2D Hadamard Transform Kernels

  • 1D Forward Kernel: $$g(x, u) = \frac{1}{N} (-1)^{\sum_{i=0}^{n-1} b_i(x) b_i(u)}$$ where $b_i(x)$ and $b_i(u)$ represent binary bits, and bit additions in exponents are computed modulo-2 (bitwise XOR).
  • 1D Forward Transform: $$H(u) = \frac{1}{N} \sum_{x=0}^{N-1} f(x) (-1)^{\sum_{i=0}^{n-1} b_i(x) b_i(u)}$$
  • 2D Forward Kernel: $$g(x, y, u, v) = \frac{1}{N} (-1)^{\sum_{i=0}^{n-1} \left[ b_i(x) b_i(u) + b_i(y) b_i(v) \right]}$$ (Forward and inverse kernels are identical).

2. Hadamard Matrix & Recursive Generation

Omitting the $\frac{1}{N}$ scaling factor converts the kernel into a binary matrix containing $+1$ and $-1$ elements (denoted as $+$ and $-$).

  • Lowest-Order Hadamard Matrix ($N = 2$): $$H_2 = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$$
  • Recursive Matrix Construction: A Hadamard matrix of dimension $2N$ is generated recursively from $H_N$: $$H_{2N} = \begin{bmatrix} H_N & H_N \\ H_N & -H_N \end{bmatrix}$$

3. Sequency Concept & Ordered Hadamard Transform

A. Unordered Sequency Issue

  • Sequency: Defined as the number of sign changes along a row or column of the matrix (analogous to frequency).
  • For a standard $8 \times 8$ Hadamard matrix, the number of sign changes along columns $u = 0, 1, 2, 3, 4, 5, 6, 7$ occurs in the unordered sequence: $0, 7, 3, 4, 1, 6, 2, 5$.

B. Ordered (Sequency-Ordered) Hadamard Kernel

To order the sequencies monotonically ($0, 1, 2, 3, \dots$), bit permutations $p_i(u)$ replace $b_i(u)$:

$$g(x, u) = \frac{1}{N} (-1)^{\sum_{i=0}^{n-1} b_i(x) p_i(u)}$$

Where $p_i(u)$ is derived via modulo-2 bit addition:

$$p_0(u) = b_{n-1}(u)$$ $$p_1(u) = b_{n-1}(u) \oplus b_{n-2}(u)$$ $$p_2(u) = b_{n-2}(u) \oplus b_{n-3}(u)$$ $$p_{n-1}(u) = b_1(u) \oplus b_0(u)$$

C. Relationship to Walsh Transform

The basis functions of the Ordered Hadamard Transform are identical to the Walsh Transform basis functions, differing only in their ordering. Consequently, the combined term Walsh-Hadamard Transform is frequently used. Ordered Hadamard displays higher energy compaction than Walsh, but remains lower than DCT.


Lecture 30 β€” KL Transform – I


1. Core Difference: Data-Dependent Kernels

Unlike DFT, DCT, Walsh, and Hadamard transforms (which feature fixed, data-independent kernels), the Karhunen-Loève (K-L) Transform (also known as the Hotelling Transform or Principal Component Analysis) derives its transformation kernel directly from the statistical properties of the input data.


2. Statistical Vector Formulation & Eigen-Decomposition

  1. Vector Population ($X$): Let $X = [x_1, x_2, \dots, x_n]^T$ be a population of $n$-dimensional vectors.
  2. Mean Vector ($\mu_X$): $$\mu_X = E[X] = \frac{1}{M} \sum X$$
  3. Covariance Matrix ($C_X$): $$C_X = E\left[(X - \mu_X)(X - \mu_X)^T\right]$$ $C_X$ is a real, symmetric $n \times n$ matrix. Diagonal elements $C_{ii}$ represent variances, while off-diagonal elements $C_{ij}$ represent covariances.
  4. Orthonormal Eigenvectors: Because $C_X$ is real and symmetric, it yields $n$ orthonormal eigenvectors $e_i$ corresponding to sorted eigenvalues $\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_n$.
  5. Transformation Matrix ($A$): Matrix $A$ is constructed with eigenvectors $e_i$ as its rows, arranged in descending order of eigenvalue magnitude (row 1 corresponds to $\lambda_1$, row $n$ to $\lambda_n$).

3. Forward KL Transform & Uncorrelated Property

  • Forward Transformation: $$y = A(x - \mu_X)$$
  • Properties of Transformed Vectors $y$:
    1. Zero Mean: $\mu_Y = 0$.
    2. Diagonal Covariance Matrix ($C_Y$): $$C_Y = A C_X A^T = \begin{bmatrix} \lambda_1 & 0 & \dots & 0 \\ 0 & \lambda_2 & \dots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \dots & \lambda_n \end{bmatrix}$$
    3. Uncorrelated Components: Because all off-diagonal elements of $C_Y$ are strictly $0$, all elements of vector $y$ are completely uncorrelated.

4. Step-by-Step Numerical Walkthrough

Consider 8 two-dimensional object pixel vectors $X$: $(3,4)^T, (4,3)^T, (4,4)^T, (4,5)^T, (5,4)^T, (5,5)^T, (5,6)^T, (6,5)^T$.

  1. Mean Vector ($\mu_X$): $$\mu_X = \begin{bmatrix} 4.5 \\ 4.5 \end{bmatrix}$$
  2. Covariance Matrix ($C_X$): $$C_X = \begin{bmatrix} 0.75 & 0.375 \\ 0.375 & 0.75 \end{bmatrix}$$
  3. Eigenvalues ($\lambda$): Setting $|C_X - \lambda I| = 0 \implies (0.75 - \lambda)^2 = 0.375^2$ yields: $$\lambda_1 = 1.125, \quad \lambda_2 = 0.375$$
  4. Eigenvectors ($e_1, e_2$): $$e_1 = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ 1 \end{bmatrix}, \quad e_2 = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 \\ -1 \end{bmatrix}$$
  5. Transformation Matrix ($A$): $$A = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$$
  6. Geometric Interpretation: Establishing matrix $A$ sets up a new coordinate system whose origin lies at the centroid of the object ($\mu_X$), with axes rotated parallel to eigenvectors $e_1$ and $e_2$.

Lecture 31 β€” KL Transform – II


1. Exact Inverse KL Transform

Because rows of $A$ are orthonormal eigenvectors, $A^{-1} = A^T$. The exact inverse reconstruction is:

$$x = A^T y + \mu_X$$

2. Truncated KL Transform & Minimization of Error

A. Dimensionality Reduction

Construct a reduced transformation matrix $A_k$ of dimension $k \times n$ using only the first $k$ eigenvectors corresponding to the $k$ largest eigenvalues ($k < n$):

$$y = A_k (x - \mu_X) \quad (\text{yields reduced vector } y \text{ of dimension } k \times 1)$$

B. Approximate Reconstruction ($\hat{x}$)

Reconstructing vector $x$ from $y$ yields an $n \times 1$ approximation $\hat{x}$:

$$\hat{x} = A_k^T y + \mu_X$$

C. Optimal Mean Square Reconstruction Error ($e_{ms}$)

The mean square reconstruction error $e_{ms}$ between $x$ and $\hat{x}$ equals the sum of the discarded eigenvalues:

$$e_{ms} = \sum_{j=1}^{n} \lambda_j - \sum_{i=1}^{k} \lambda_i = \sum_{j=k+1}^{n} \lambda_j$$

Because the omitted eigenvalues are the smallest, the K-L Transform minimizes the mean square error for any choice of $k$ coefficients, making it the optimal transform.


3. Application to Image Data Compression

  1. Vectorizing Images: An $N \times N$ image is formatted into $N$ column vectors $x_i$ of dimension $N \times 1$.
  2. Statistics Computation: $$\mu_X = \frac{1}{N} \sum_{i=0}^{N-1} x_i \quad (N \times 1)$$ $$C_X = \frac{1}{N} \sum_{i=0}^{N-1} (x_i - \mu_X)(x_i - \mu_X)^T \quad (N \times N)$$
  3. Eigen-Decomposition: Computes $N$ eigenvalues $\lambda_0 \ge \lambda_1 \dots \ge \lambda_{N-1}$ and eigenvectors $e_i$.
  4. Compression Pipeline:
    • Form $A_k$ ($k \times N$) using $k$ eigenvectors.
    • Transform each column: $y_i = A_k (x_i - \mu_X)$ ($k \times 1$).
    • The compressed image matrix is of reduced size $k \times N$.
    • Saved Quantities: Matrix $A_k$, compressed vectors $y_i$, and mean vector $\mu_X$.
  5. Image Reconstruction: $$\hat{x}_i = A_k^T y_i + \mu_X$$
  6. Quality vs. Number of Eigenvectors ($k$):
    • $k = 1$: Coarse, recognizable structural image outline (demonstrating extreme energy compaction).
    • $k = 5, 25, 35, 50, 100, 128$: Image quality improves, removing artifacts until $k = N$ yields exact reconstruction.
  7. Drawback: High computational complexity ($O(N^3)$ eigen-decomposition and data-dependent matrix generation) limits K-L transform adoption in commercial image compression standards compared to DCT.

4. Comparative Summary Across Transforms

TransformKernel TypeEnergy CompactionComputational ComplexityFrequency / Physical InterpretationPrimary Application
DCTFixed (Cosines)Very High$O(N \log_2 N)$ (via Fast DCT)Spatial Frequency (Smoother $2N$ periodicity)Standard Image Compression (JPEG)
WalshFixed ($\pm 1$ products)Moderate$O(N \log_2 N)$ (via Fast Walsh)Sequency (Sign changes)Binary Signal Processing
HadamardFixed ($\pm 1$ matrices)Higher than Walsh$O(N \log_2 N)$ (Fast Hadamard)Sequency (Requires ordering)Pattern Matching / Hardware
K-L (PCA)Data-DependentOptimal (Highest)$O(N^3)$ (Eigen-decomposition)Principal Axes (Eigenvector Alignment)Pattern Recognition, Optimal Compaction

The eigenvectors are ordered according to eigenvalues.

A large eigenvalue means that direction contains a large amount of variance.

Therefore the first few transform components can often retain most of the signal information.

This gives energy/information compaction.


5. Relation to PCA

The K-L transform is closely related to what is commonly called:

$$ \boxed{\text{PCA}} $$

in modern machine learning/statistics.

The important distinction from fixed transforms such as Fourier or DCT is:

Fourier/DCT
β†’ fixed basis

K-L/PCA
β†’ basis learned from the data covariance.

Part VII β€” Point Processing and Contrast


Lecture 32 β€” Image Enhancement: Point Processing Techniques

1. Introduction & Purpose of Image Enhancement

  • Definition: Image enhancement is a processing technique applied to an image to highlight or emphasize specific features so that the resulting image is more suitable than the original for a specific application.
  • Application Dependency: Image enhancement is inherently problem-oriented:
    • A technique that works best for medical X-ray images may not be optimal for microscopic images.
    • Common goals include noise reduction, contrast expansion for dark/underexposed images, and edge/boundary highlighting.

2. Broad Categories of Image Enhancement

Image enhancement techniques fall into two primary categories:

  1. Spatial Domain Operations:
    • Operate directly on the image pixels in the spatial domain / image plane.
    • Do not require transforming pixel data into another domain before processing.
  2. Frequency Domain Operations:
    • Operate on the Discrete Fourier Transform (DFT) coefficients of the image.
    • The DFT of the image is calculated, the transform coefficients are modified (e.g., using low-pass, band-pass, or high-pass filters), and the Inverse DFT (IDFT) is applied to yield the enhanced image.

3. Spatial Domain Transformation Model

For a two-dimensional image, spatial domain operations are mathematically defined as:

$$ g(x, y) = T[f(x, y)] $$
  • $f(x, y)$: The original input image at location $(x, y)$.
  • $g(x, y)$: The processed/enhanced output image at location $(x, y)$.
  • $T$: An operator defined over a defined spatial neighborhood around the pixel location $(x, y)$ in $f$.

Neighborhood Structure

  • The neighborhood around point $(x, y)$ is typically a square sub-image centered at $(x, y)$.
  • Typical neighborhood sizes include $3 \times 3$, $5 \times 5$, $7 \times 7$, etc., depending on the application.

4. Point Processing vs. Mask Processing

Spatial domain operations are split into three key forms based on neighborhood size:

                     Spatial Domain Operations
                                 β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                       β–Ό                       β–Ό
  Point Processing       Histogram Processing     Mask Processing
  (Neighborhood: 1Γ—1)     (Special Point Form)   (Neighborhood: > 1Γ—1)

A. Point Processing ($1 \times 1$ Neighborhood)

  • Neighborhood Size: Strictly $1 \times 1$.
  • Operation: The transformation operator $T$ works on only a single pixel at location $(x, y)$. The output intensity depends solely on the input intensity at that exact location, completely ignoring neighboring pixel values.
  • Simplified Equation:
$$ s = T(r) $$

where $r$ is the input intensity value at a pixel, and $s$ is the processed intensity value at the corresponding location.


B. Mask Processing / Neighborhood Filtering ($> 1 \times 1$ Neighborhood)

  • Neighborhood Size: Greater than $1 \times 1$ (e.g., $3 \times 3$, $5 \times 5$, $7 \times 7$).
  • Operation: A spatial filter mask containing defined coefficient weights $W_{i,j}$ is centered over pixel $(x, y)$. Both the center pixel and all adjacent pixels within the mask take part in calculating the output intensity.
  • Mathematical Equation for a $3 \times 3$ Mask:
$$ g(x, y) = \sum_{i=-1}^{1} \sum_{j=-1}^{1} W_{i, j} \cdot f(x+i, y+j) $$
  • Applications: Image sharpening, spatial smoothing/averaging, and edge detection.

5. Specific Point Processing Techniques

A. Dynamic Range Mapping (Contrast Enhancement)

  • Mechanism: Maps a narrow range of input intensities $r$ to a much wider range of output intensities $s$ using a non-linear mapping curve $s = T(r)$.
  • Visual Effect: Stretches dark or mid-tone regions to improve contrast and feature visibility.

B. Thresholding Operation

  • Mechanism: Maps input intensities relative to a threshold value $I$:
    • If $r < I \implies s = 0$ (low intensity / black).
    • If $r \ge I \implies s = s_{\max}$ (maximum intensity / white).
  • Result: Generates a binary (black-and-white) image.

C. Image Negative Transformation

1. Motivation

  • In images where small gray/white details are embedded within a predominantly dark or black background, visual extraction of features is difficult.
  • Inverting intensities makes dark background pixels bright and light details dark, significantly improving visual feature extraction.

2. Mathematical Definition

For an image with $L$ discrete gray levels ranging from $0$ to $L - 1$:

$$ s = T(r) = L - 1 - r $$
  • When input $r = 0$ (minimum / black) $\implies s = L - 1$ (maximum / white).
  • When input $r = L - 1$ (maximum / white) $\implies s = 0$ (minimum / black).

3. Graphical Representation

  • Represented in the $r-s$ coordinate plane as a straight line with a slope of $-45^\circ$.
  • Passes through the points $(0, L-1)$ and $(L-1, 0)$.

4. Clinical Application Example: Digital Mammogram

  • In a raw digital mammogram, cancerous regions and tissue grains appear as faint white patches/grains against a dark background.
  • Applying the negative transformation $s = L - 1 - r$ converts the dark background to a light background and tissue/cancerous structures to dark details.
  • This inversion makes structural diagnosis and tissue inspection much clearer and more convenient for medical interpretation.

Lecture 33 β€” Contrast Stretching Operation

1. Contrast Stretching Operation & Point Transformations

A. Causes of Dark / Low-Contrast Images

Images acquired from imaging devices frequently exhibit poor contrast or dark appearances due to three primary physical reasons:

  1. Poor Scene Illumination: The object or environment being photographed has insufficient lighting.
  2. Narrow Dynamic Range of Sensor: The dynamic range (the difference between the minimum and maximum intensity values a sensor can detect) is too small to capture scene variations.
  3. Improper Aperture Settings: Lens aperture is set too small, restricting light reaching the image sensor.

B. Contrast Stretching Transformation Function

  • Piecewise Linear Mapping: Uses control points $(r_1, s_1)$ and $(r_2, s_2)$ to alter input intensities $r$ to output intensities $s$.
  • Key Special Cases:
    • Identity Transformation ($r_1 = s_1$ and $r_2 = s_2$): Forms a $45^\circ$ straight line ($s = r$), producing no intensity change in the output image.
    • Thresholding ($r_1 = r_2, s_1 = 0, s_2 = L-1$): Converts a low-contrast image directly into a binary (black & white) image.
    • Standard Enhancement ($r_1 < r_2$ and $s_1 < s_2$): Expands the dynamic range of intermediate gray levels.
  • Monotonicity Condition ($r_1 \le r_2$ and $s_1 \le s_2$): Ensures that the transformation function $T(r)$ is single-valued and monotonically increasing. This maintains intensity orderβ€”dark pixels remain darker, and bright pixels remain brighter in the output image.

C. Dynamic Range Compression (Logarithmic Transformation)

  • Problem: Certain mathematical transforms (e.g., 2D Discrete Fourier Transform magnitude spectra) yield a dynamic range spanning from $0$ to thousands, exceeding display capabilities (typically 8-bit, $0-255$). Displaying raw data shows only a central bright dot while suppressing faint surrounding details.
  • Logarithmic Formula:
$$ s = T(r) = c \log(1 + r) $$

where $c$ is a scaling constant. The term $1 + r$ prevents $\log(0)$ calculation errors when $r = 0$.

  • Effect: Compresses high dynamic range values while expanding lower intensity ranges, revealing hidden spectral details.

D. Power-Law (Gamma) Transformation & $\gamma$-Correction

  • Formula:
$$ s = T(r) = c r^\gamma $$
  • Behavior:
    • $\gamma < 1$: Expands low-intensity (dark) ranges and compresses high-intensity ranges.
    • $\gamma > 1$: Compresses low-intensity ranges and expands high-intensity ranges.
  • Device Calibration ($\gamma$-Correction):
    • Physical display devices (such as CRT monitors) exhibit intrinsic power-law responses, typically $s = r^{2.5}$ ($\gamma = 2.5$), which darkens images.
    • Correction: Pre-transform input images using $s = r^{1/2.5} = r^{0.4}$. When processed by the monitor, the device’s $r^{2.5}$ distortion nullifies the pre-correction, yielding faithful image reproduction.
  • Controlled Image Enhancement: Adjusting $\gamma$ allows selective enhancement (e.g., restoring washed-out aerial images by setting $\gamma > 1$).

E. Gray Level Slicing

  • Purpose: Highlights specific intensity ranges $[A, B]$ of interest:
    1. With Background Suppression: Sets intensities in $[A, B]$ to a high value and sets all other intensities to $0$.
    2. With Background Retention: Enhances intensities in $[A, B]$ while leaving all other pixel intensities unchanged.

Part VIII β€” Histogram Equalization and Specification


Lecture 34 β€” Histogram Equalization and Specification – I

1. Definition of Image Histogram

  • Global Appearance Representation: An image histogram represents the global frequency distribution of intensity levels without preserving spatial context or pixel layout.
  • Mathematical Definitions ($L$ discrete gray levels, $r_k \in [0, L-1]$):
    • Unnormalized Histogram: $h(r_k) = n_k$, where $n_k$ is the number of pixels with intensity $r_k$.
    • Normalized Histogram (PDF):
$$ p(r_k) = \frac{n_k}{n} $$
where $n$ is the total pixel count in the image. $p(r_k)$ represents the probability of occurrence of intensity $r_k$.

2. Image Categories vs. Histogram Profiles

Image CategoryHistogram CharacteristicsVisual Appearance
Dark ImageConcentrated heavily near intensity $0$Dark, details obscured in shadows
Bright ImageConcentrated heavily near intensity $L-1$ ($255$)Light/washed-out appearance
Low Contrast ImageNarrow peak concentrated in the middle rangeMuddy gray, low variation
High Contrast ImageUniform, wide distribution spanning $0$ to $255$Clear, crisp details across all ranges

3. Continuous Histogram Equalization Derivation

  • Transformation Function: $s = T(r)$ for normalized continuous intensities $r, s \in [0, 1]$.
  • Required Conditions on $T(r)$:
    1. $T(r)$ is single-valued and monotonically increasing for $0 \le r \le 1$ (preserves intensity ordering).
    2. $0 \le T(r) \le 1$ for $0 \le r \le 1$ (guarantees output remains within valid range).
  • Cumulative Distribution Function (CDF) as $T(r)$:
$$ s = T(r) = \int_0^r p_r(w) \, dw $$
  • Proof of Uniform Output Density $p_s(s)$: Taking the derivative yields $\frac{ds}{dr} = p_r(r)$. Applying fundamental probability transformation theory:
$$ p_s(s) = p_r(r) \left| \frac{dr}{ds} \right| = p_r(r) \cdot \frac{1}{p_r(r)} = 1 \quad \text{for } 0 \le s \le 1 $$
  • Conclusion: Using the input CDF as the transformation function produces a perfectly uniform probability density function $p_s(s) = 1$, maximizing dynamic range and global contrast.

Lecture 35 β€” Histogram Equalization and Specification – II

1. Discrete Histogram Equalization Formulation

  • Discrete Mapping Function:
$$ s_k = T(r_k) = \sum_{i=0}^k p_r(r_i) = \sum_{i=0}^k \frac{n_i}{n} $$
  • Limitation of Histogram Equalization: Fully automatic and parameter-free. It produces a single fixed result and cannot support interactive or region-specific contrast manipulation.

2. Histogram Specification (Matching)

  • Objective: Transform an input image $r$ with PDF $p_r(r)$ into an output image $z$ matching a specified target PDF $p_z(z)$.

A. Continuous Theory

  1. Equalize input image $r \to s$:
$$ s = T(r) = \int_0^r p_r(w) \, dw $$
  1. Compute CDF of target PDF $p_z(z)$:
$$ v = G(z) = \int_0^z p_z(t) \, dt $$
  1. Equate $v = s \implies G(z) = T(r) = s$.
  2. Apply inverse transformation to obtain output $z$:
$$ z = G^{-1}(s) = G^{-1}[T(r)] $$

B. Discrete Theory & Iterative Mapping

  1. Compute discrete input CDF $s_k = T(r_k) = \sum_{i=0}^k p_r(r_i)$.
  2. Compute discrete target CDF $v_k = G(z_k) = \sum_{i=0}^k p_z(z_i)$.
  3. Solve $z_k = G^{-1}(s_k)$ iteratively using arrays/lookup tables by finding the smallest integer $\hat{z}_k$ satisfying:
$$ G(\hat{z}_k) - s_k \ge 0 $$

Lecture 36 β€” Histogram Implementation – I

1. Post-Processing Scaling Formula

Because discrete mapping $s_k = T(r_k)$ yields values in $[0, 1]$, output values are scaled to discrete levels $0, 1, \dots, L-1$ (where $L=256$):

$$ s_k' = \text{Int}\left[ \frac{s_k - s_{\min}}{1 - s_{\min}} \times (L-1) + 0.5 \right] $$

2. Worked Walkthrough Example: Equalization ($L = 8$)

Given Input Distribution:

Discrete levels $r \in \{0, 1, 2, 3, 4, 5, 6, 7\}$ ($L-1 = 7$):

$$ p_r(0)=0, \quad p_r(1)=0.1, \quad p_r(2)=0.1, \quad p_r(3)=0.3, \quad p_r(4)=0, \quad p_r(5)=0, \quad p_r(6)=0.4, \quad p_r(7)=0.1 $$

Step-by-Step Computation Table:

Input Level ($r_k$)Input $p_r(r_k)$CDF $s_k = T(r_k)$Scaled $s_k'$ CalculationFinal Mapped Level ($s_k'$)
0$0.0$$0.0$$\text{Int}[0.0 \times 7 + 0.5]$0
1$0.1$$0.1$$\text{Int}[\frac{0.1 - 0.1}{1 - 0.1} \times 7 + 0.5]$1
2$0.1$$0.2$$\text{Int}[\frac{0.2 - 0.1}{0.9} \times 7 + 0.5]$2
3$0.3$$0.5$$\text{Int}[\frac{0.5 - 0.1}{0.9} \times 7 + 0.5]$4
4$0.0$$0.5$$\text{Int}[\frac{0.5 - 0.1}{0.9} \times 7 + 0.5]$4
5$0.0$$0.5$$\text{Int}[\frac{0.5 - 0.1}{0.9} \times 7 + 0.5]$4
6$0.4$$0.9$$\text{Int}[\frac{0.9 - 0.1}{0.9} \times 7 + 0.5]$7
7$0.1$$1.0$$\text{Int}[\frac{1.0 - 0.1}{0.9} \times 7 + 0.5]$7
  • Final Mapping Summary: $0 \to 0$, $1 \to 1$, $2 \to 2$, $3 \to 4$, $4 \to 4$, $5 \to 4$, $6 \to 7$, $7 \to 7$.

3. Why Discrete Equalization Does Not Yield a Flat Histogram

In discrete images, gray levels are quantized integers. Summing discrete probabilities maps multiple input gray levels to single output bins. Empty bins in the input histogram remain empty, resulting in a stepped or near-uniform distribution rather than a strictly flat continuous line.


Lecture 37 β€” Histogram Implementation – II & Image Operations

1. Worked Walkthrough Example: Specification ($L = 8$)

Input CDF ($s_k$) & Target Distribution ($p_z(z)$):

  • Target $p_z(z)$: $p_z(0)=0, p_z(1)=0.1, p_z(2)=0.2, p_z(3)=0.4, p_z(4)=0.2, p_z(5)=0.1, p_z(6)=0, p_z(7)=0$.
  • Target CDF $G(z_k)$: $G(0)=0, G(1)=0.1, G(2)=0.3, G(3)=0.7, G(4)=0.9, G(5)=1.0, G(6)=1.0, G(7)=1.0$.

Matching Iterative Condition ($G(\hat{z}) - s_k \ge 0$):

Input $r_k$Input $s_k$Search Condition ($G(\hat{z}) \ge s_k$)Matched Target Level ($z_k'$)
0$0.0$$G(0) = 0.0 \ge 0.0$0
1$0.1$$G(1) = 0.1 \ge 0.1$1
2$0.2$$G(2) = 0.3 \ge 0.2$2
3$0.5$$G(3) = 0.7 \ge 0.5$3
4$0.5$$G(3) = 0.7 \ge 0.5$3
5$0.5$$G(3) = 0.7 \ge 0.5$3
6$0.9$$G(4) = 0.9 \ge 0.9$4
7$1.0$$G(5) = 1.0 \ge 1.0$5
  • Final Specification Mapping ($r \to z'$): $0 \to 0, 1 \to 1, 2 \to 2, 3 \to 3, 4 \to 3, 5 \to 3, 6 \to 4, 7 \to 5$.

2. Image Differencing (Subtraction)

  • Equation:
$$ g(x, y) = f(x, y) - h(x, y) $$
  • Medical Application β€” Mask Mode Radiography:
    1. Capture an initial X-ray frame before injecting contrast media (the Mask).
    2. Inject contrast media into the patient’s bloodstream and capture subsequent X-ray frames.
    3. Subtract the mask from post-injection frames ($g = f_{\text{post}} - f_{\text{mask}}$).
    4. Outcome: Cancels out static background bones and soft tissue, highlighting blood vessel structures to detect arterial blockages and disorders.

3. Image Averaging (Noise Reduction)

  • Additive Noise Model: $g(x, y) = f(x, y) + \eta(x, y)$, where $\eta(x, y)$ is uncorrelated zero-mean noise with variance $\sigma_\eta^2$.
  • Averaging $K$ Frames:
$$ \bar{g}(x, y) = \frac{1}{K} \sum_{i=1}^K g_i(x, y) $$
  • Properties:
    • $E[\bar{g}(x, y)] = f(x, y)$
    • Noise variance decreases to $\sigma_{\bar{g}}^2 = \frac{1}{K} \sigma_\eta^2$, reducing noise standard deviation by $\sqrt{K}$.
  • Application: Used in astronomical imaging (e.g., galaxy observations) where faint light signals are dominated by sensor noise; averaging 128 frames drastically cancels background noise.

4. Conceptual Review Questions & Solutions

  1. What effect does a second pass of histogram equalization have on an already equalized image?
    • Theoretical Answer: An equalized image has a flat PDF $p_s(s) = 1$. Computing its CDF produces an identity linear mapping $s = r$ ($45^\circ$ line). Thus, a second pass has zero additional effect.
    • Practical Answer: Due to discrete quantization and non-flat histograms, minor residual adjustments occur, but the overall effect is negligible.
  2. What condition must be satisfied by the target histogram in histogram specification?
    • The transformation function $G(z)$ must be strictly monotonically increasing, which requires the target probability $p_z(z) > 0$ for all discrete intensity levels $z$.