This study guide is organized as an exam-preparation reference for 4th-year Computer Engineering students taking Computer Vision / Digital Image Processing. It covers the physics, mathematical foundations, algorithmic mechanics, and computer engineering trade-offs across Chapters 1 through 5.


Chap. 1: Image Acquisition

1. Digital Cameras & Image Sensors (CCD vs. CMOS)

Digital cameras convert photons (light energy) into discrete digital values ( for an 8-bit channel).

  • Charge-Coupled Device (CCD):
    • Mechanism: Incoming photons generate photoelectrons trapped in potential wells. During readout, these charge packets are shifted row-by-row into a horizontal shift register and converted to voltage at a single readout amplifier, followed by an external Analog-to-Digital Converter (ADC).
    • Characteristics: High signal-to-noise ratio (SNR), high dynamic range, uniform response, but high power consumption and slow readouts.
    • Shutter mechanism: Inherently supports Global Shutter (all pixels expose and transfer charge simultaneously).
  • Complementary Metal-Oxide-Semiconductor (CMOS):
    • Mechanism: Every individual pixel (Active Pixel Sensor - APS) contains its own photodiode, reset transistor, source-follower amplifier, and row-select transistor. Column-parallel ADCs convert signals directly on the chip.
    • Characteristics: Fast, low power, cheaper to fabricate on standard silicon lines, but introduces fixed-pattern noise (FPN) requiring Correlated Double Sampling (CDS).
    • Shutter mechanism: Typically uses Rolling Shutter (rows are exposed and read sequentially).
    • CV Implication of Rolling Shutter: Rapidly moving objects undergo geometric distortions (e.g., rotating fan blades appear curved, vertical poles lean horizontally during rapid camera panning).
   Rolling Shutter Exposure:                 Distortion Effect on Moving Car:
   Row 0: |---|                                  /======\
   Row 1:   |---|                               /        \
   Row 2:     |---|            ====>           /__________\
   Row 3:       |---|                         (O)        (O)  (Sheared shape)
         Time --->

2. Thin Lens Optics (with Grade 12 Lens Physics)

The Thin Lens Formula and Sign Conventions

A thin lens has a thickness negligible compared to its radii of curvature. The interaction between object distance (), image distance (), and focal length () is governed by the Gaussian Thin Lens Equation:

Cartesian / Real-is-Positive Sign Convention:

  • for converging (convex) lenses; for diverging (concave) lenses.
  • for a real object in front of the lens.
  • if the image is real (formed behind the lens, captured by an image sensor).
  • if the image is virtual (formed on the same side as the object, cannot be projected onto a sensor).

Linear (Lateral) Magnification ():

  • is object height, is image height.
  • If , the image is inverted (standard real image on camera sensor).
  • If , the image is diminished; if , it is magnified.

Lensmaker’s Equation:

Where is the refractive index of the glass, and are the radii of curvature of the two lens surfaces.


Grade 12 Physics Exam-Style Worked Problem

Problem:

A robot vision camera uses a thin biconvex lens with a focal length of .

  1. A marker of height is positioned at a distance of () along the optical axis.
    • Calculate the distance behind the lens where the CMOS sensor must be placed to obtain a sharp image.
    • Compute the lateral magnification and the size of the marker projected onto the sensor .
  2. If the marker suddenly moves to in front of the lens, determine the new image distance , state whether the image can be captured by the sensor, and explain why.

Solution:

Part 1: Given:

Using the thin lens equation: Find a common denominator: (The sensor must be placed behind the lens optical center).

Magnification: (The image is inverted and scaled down to of original size).

Image size on sensor: The height of the marker on the sensor is (inverted).


Part 2: Given:

Conclusion & Justification: , which signifies a virtual, upright image located on the object’s side of the lens. A physical CMOS sensor placed behind the lens cannot capture this image because the rays diverge after exiting the lens and do not physically converge onto a focal plane.


3. Camera Parameters & The Exposure Triangle

Exposure is the total quantity of light energy reaching the sensor per unit area:

                           EXPOSURE TRIANGLE
                            Aperture (f-stop)
                             /             \
                   Depth of Field       Motion Blur
                         /                     \
      Shutter Speed  -------------------------  ISO Sensitivity
                              Sensor Noise

1. Aperture & F-Number ()

  • The aperture is the physical opening diameter () of the diaphragm.
  • F-number (): Defined as the ratio of focal length to pupil diameter:
  • Standard f-stops follow a factor sequence: .
  • Each step up cuts the aperture area () by half, reducing light transmission by .

2. Shutter Speed ()

  • The duration the sensor collects photons (e.g., to ).
  • Fast shutter: Freezes high-speed motion; requires high illumination or wide aperture.
  • Slow shutter: Collects more photons in low light; introduces motion blur, which acts as a low-pass directional filter in spatial domain:

3. ISO Sensitivity

  • The analog and digital gain applied to the voltage read from the photodiodes before ADC quantization.
  • Trade-off: Doubling ISO doubles signal brightness without changing the physical photon count, which directly amplifies background thermal noise and shot noise, degrading the Signal-to-Noise Ratio (SNR).

4. Depth of Field (DOF) & Circle of Confusion (CoC)

  • Circle of Confusion (): When an object is out of focus, a point source in object space is projected not onto an infinitesimal point on the sensor, but as a disk of blur. The maximum blur diameter that the human eye or sensor pixel grid considers indistinguishable from a sharp point is .
  • Depth of Field: The distance range in front of and behind the focused distance () where blur remains .
  • Hyperfocal Distance (): The closest focus distance at which DOF extends to infinity:
  • Near and Far Limits:
  • Engineering rule:
    • Large Aperture (small , e.g., ) Shallow DOF (background is blurred; useful for portrait segmentation).
    • Small Aperture (large , e.g., ) Deep DOF (entire scene in focus; ideal for SLAM / visual odometry).

5. Auto-Focus (AF)

| Mechanism | Operating Principle | Advantages | Disadvantages | | :------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- | | CDAF (Contrast Detection AF) | Evaluates image high frequencies (spatial gradient variance via Sobel/Laplacian). Stepper motor sweeps lens until focus measure peaks: . | Highly accurate; no calibration needed; uses the primary imaging sensor. | Slow “hunting” behavior (lens overshoots to verify peak); struggles in low-contrast scenes. | | PDAF (Phase Detection AF) | Employs dedicated microlenses/masked pixel pairs splitting light exiting opposing sides of lens exit pupil. Measures horizontal phase shift between two rays. | Fast, single-shot calculation; directly tells the direction and distance to move the lens. | Historically required separate sensor; complex pixel fabrication on sensor (masked photodiode pairs). |


6. White Balance (WB) & Chromatic Adaptation

  • Color Temperature (): Measured in Kelvin (K), following Planckian blackbody radiation.
    • Tungsten light (red/orange-shifted).
    • Daylight (neutral).
    • Overcast / Shade (blue-shifted).
  • Von Kries Chromatic Adaptation Model: Assumes illumination changes can be modeled as independent diagonal gain adjustments per sensor color channel:
  • Gray-World Assumption: Assumes the spatial average of reflectance in an arbitrary natural scene is achromatic neutral gray ().

Chap. 2: Digital Image Fundamentals

Continuous World                Sampling               Quantization           Digital Image
f(x, y) Continuous  ======>  Spatial Grid (M x N)  ===>  Discrete Levels (L)  ===> Matrix I[r, c]

1. The Sampling Theorem & Aliasing

  • Sampling: Discretization of the continuous spatial coordinates onto a 2D lattice.
  • Nyquist-Shannon Theorem: To reconstruct a continuous 2D spatial signal containing maximum spatial frequencies without information loss, the sampling frequencies must satisfy:
  • Aliasing: When sampling frequency , high-frequency scene details fold back (mirror) into lower frequencies:
    • Visual artifacts: Moiré patterns (stripes on brick walls or fine fabric), jagged step edges (“jaggies”).
    • Antialiasing Solution: Place an Optical Low-Pass Filter (OLPF) (birefringent quartz crystal) in front of the sensor to blur out frequencies beyond the sensor’s Nyquist limit prior to sampling.
       Continuous Wave (High freq):   /\  /\  /\  /\  /\  /\  /\  /\
       Sampling Points (*):          *       *       *       *
       Reconstructed (Aliased):      \_______/       \_______/  (Lower freq!)

Slit Animation (Barrier-Grid / Picket-Fence Effect)

Slit animation overlay utilizes a moving set of vertical slits (grating) over an interlaced composite printed image. This is a physical demonstration of spatial subsampling:

  • The barrier allows the eye to integrate only a specific phase-shifted spatial sample of the underlying image at any given position.
  • When the slit raster translates horizontally by distance , the visible spatial sample steps to the next phase, producing the illusion of smooth temporal motion.
  • In computer vision, this physical phenomenon parallels temporal aliasing (wagon-wheel effect in video frame acquisition) and spatial phase sampling in structured-light 3D scanners.

2. Quantization & Dynamic Range

  • Quantization: Discretization of continuous light amplitude (radiance) into integer levels.
  • Uniform Quantizer: Maps an intensity interval into steps of width .
  • False Contouring: Occurs when bit-depth is too low (). Smooth gradients show discrete step-like boundaries because quantization noise becomes correlated with image content.

3. Bit-Plane Decomposition & Digital Watermarking

An 8-bit grayscale pixel can be decomposed into an 8-term binary sum: Where is the Least Significant Bit (LSB) and is the Most Significant Bit (MSB).

Bit Plane 7 (MSB): [ 128 ] -> Contains structural, edge, and major contrast data.
Bit Plane 6:       [  64 ] -> High structural information.
...
Bit Plane 1:       [   2 ] -> Visually indistinct, high spatial variation.
Bit Plane 0 (LSB): [   1 ] -> Appears as pure random noise; carries ~0.4% luminance impact.

Digital Watermarking via LSB Insertion

Since bit-plane 0 contributes imperceptibly to human vision, we can replace with a binary secret payload/watermark :

  • Trade-off & Vulnerability:
    • Advantage: Extremely fast encoding; zero perceptual degradation.
    • Critical Weakness: Fragile. Any JPEG lossy compression, histogram equalization, spatial filtering (LPF), or cropping strips or corrupts the LSB entirely. For robustness, watermarks must be inserted in the frequency domain (e.g., mid-band DCT or DWT coefficients).

Chap. 3: Intensity Transformations & Image Quality

Intensity transformations operate purely on single pixels: , where is input intensity and is output intensity.

          s (Output)
         1.0 |      / (Log / Gamma < 1)  - Expands dark tones
             |    /
             |  /   (Identity: s = r)
             | /
             |/____ (Gamma > 1)          - Compresses dark tones
             0------------------ 1.0  r (Input)

1. Log Transformations

  • Function: Stretches the dynamic range of low, dark pixel values while heavily compressing higher, bright values.
  • Primary Application: Displaying the Fourier Transform 2D Magnitude Spectrum . Dynamic range in frequency space can span units; the DC component overwhelms the display unless scaled logarithmically:

2. Power-Law (Gamma) Transformations

  • Case : The curve bends upward. Low intensities are mapped to broader ranges of output Brightens dark shadows, revealing obscured details in underexposed scenes.
  • Case : The curve bends downward. High intensities are expanded, darks are compressed Darkens overall image, increases high-end contrast in washed-out/overexposed scenes.
  • Display Gamma Correction: Standard displays have a natural non-linear response of approximately . Video pipelines pre-compensate by applying so the combined physical output is linear:

3. Histogram Equalization (HE)

Mathematical Derivation (Continuous Domain)

Let be continuous pixel intensities with Probability Density Function (PDF) . We seek an invertible, monotonically increasing transformation such that output PDF is uniform: over .

From fundamental probability theory for transformed random variables: Since we require : Integrating both sides:

Discrete Transformation Algorithm

For an image with discrete levels ():

  1. Compute Histogram: Count pixel frequencies for each intensity , where .
  2. Compute Discrete PDF:
  3. Compute Discrete CDF and Mapping Function:
  4. Remap Pixels: Assign each original pixel with value to new value .
  • Usage & Artifacts: Automatically enhances global contrast across flatly illuminated or hazy images.
  • Limitation: Often amplifies background noise and causes unnatural, harsh visual artifacts because it acts globally. This motivates CLAHE (Contrast Limited Adaptive Histogram Equalization) for local regions.

4. Image Quality Assessment (IQA) Metrics

Let be the ground-truth/reference image and be the degraded/test image of size .

1. Root Mean Squared Error (RMSE)

Measures absolute pixel-by-pixel intensity error. Simple, but poorly correlated with human perceptual judgment (e.g., uniform 1-pixel shift yields high RMSE despite high perceptual quality).

2. Peak Signal-to-Noise Ratio (PSNR)

  • For an 8-bit image, .
  • Typical acceptable lossy image compression values: .
  • If , .

3. Zero-Mean Normalized Cross-Correlation (ZNCC)

Used extensively for template matching and stereo depth disparity:

  • Key Property: Normalized to . Invariant to affine illumination shifts ( where ), making it robust against changing lighting conditions.

4. Structural Similarity Index Measure (SSIM)

SSIM evaluates visual degradation by decomposing the evaluation into three orthogonal terms: Luminance, Contrast, and Structure.

Setting weights : Where:

  • : Local mean intensities (luminance estimation).
  • : Local sample variances (contrast estimation).
  • : Cross-covariance between patches and (structural correlation).
  • : Regularization constants (with ) to prevent division by zero when local denominators vanish.
  • , where indicates structural identity.

Chap. 4: Color Models

1. Color Filter Array (CFA) & Demosaicing

Digital image sensors are inherently panchromatic (color-blind, counting incoming photons regardless of wavelength). To construct a color image, an absorption filter mask is deposited over the pixel array.

       Bayer Filter Layout (2 x 2 Repeat Pattern):
       +-------+-------+
       |   R   |   G   |   -> Red:   25% of surface
       +-------+-------+
       |   G   |   B   |   -> Green: 50% of surface
       +-------+-------+   -> Blue:  25% of surface
  • Why 50% Green? The human visual system’s photopic luminous efficiency function peaks at (green band). The eye is significantly more sensitive to spatial detail/sharpness in green wavelengths than in red or blue.
  • Demosaicing: The process of interpolating missing color components at each pixel location.
    • Bilinear Demosaicing: Reconstructs missing channels by averaging immediate orthogonal or diagonal neighbors of that specific missing color.
    • Flaw: Bilinear filtering blurs across high-contrast edges, resulting in high-frequency “zipper artifacts” (color fringes) along sharp boundaries. Advanced algorithms use edge-directed color-difference interpolation ( and ).

2. RGB Color Model

  • Coordinate Representation: Additive color space formed by a unit cube with axes Red, Green, and Blue or .
  • Vertices:
    • Black, White.
    • Main diagonal connects Black to White (Achromatic Gray Line).
  • Limitation in Computer Vision:
    • Coupled Chrominance and Luminance: If a shadow falls across an object, all three color channels scale down proportionally.
    • Pixel-level color tracking using RGB Euclidean distance is susceptible to false positives/negatives under variable lighting conditions.

3. HSI / HSV Color Model

Decouples chromatic information (color content) from achromatic light intensity (illumination).

                 HUE (Angle 0 to 360 deg)
                        Red (0 deg)
                      /            \
          Magenta                    Yellow (60 deg)
            |                             |
       Blue (240 deg)                Green (120 deg)
                      \            /
                           Cyan

       Saturation: Radial distance from center (0 at axis, 1 at boundary).
       Intensity / Value: Vertical axis (0 at bottom, 1 at top).
  • Hue (): Encodes the pure dominant wavelength of the color.
  • Saturation (): Encodes the degree of dilution by white light (purity).
  • Intensity () or Value (): Encodes brightness / energy.

RGB to HSI Conversion Math

Given normalized to :

Where:

Computer Vision Engineering Application: Robust Color Segmentation

In tasks such as autonomous vehicle lane marking or traffic cone tracking, illumination varies widely (direct sunlight vs. shadows).

  • Method: Convert input image to HSV/HSI. Discard or widen threshold on the or channel; place tight bounding thresholds solely on the Hue channel () and a minimum Saturation threshold ().
  • Result: Targets inside shadows are segmented accurately because shadow alters while leaving largely unchanged.

Chap. 5 (Part 1): Image Filtering in the Spatial Domain

1. Spatial Filtering Basics: Correlation vs. Convolution

For an image and a kernel :

  • 2D Cross-Correlation ():
  • 2D Convolution ():
  • Difference: Convolution requires flipping the kernel by prior to sliding. If the kernel is symmetric (, like a Gaussian kernel), correlation and convolution produce identical results.

2. Linear Filters

A. Low-Pass Filters (LPF) / Smoothing Filters

Attenuate high spatial frequencies (edges, fine details, noise) while preserving low spatial frequencies (homogeneous backgrounds).

1. Box Filter (Mean/Average)

Every kernel element has an identical weight: Drawback: Poor frequency response; produces ringing and harsh, rectangular blur artifacts.

2. Gaussian Filter

The standard continuous isotropic 2D Gaussian function is:

  • Kernel values decay smoothly away from the center pixel.
  • Advantage: Isotropic (rotationally invariant), eliminates high frequencies without introducing ringing artifacts in the frequency domain.

B. High-Pass Filters (HPF) & Sharpening

Attenuate low frequencies and amplify high frequencies (emphasize discontinuities, step edges, and fine details).

1. Laplacian Filter (2nd-order differential)

Isotropic operator tracking second derivatives:

Finite difference approximation: Yielding the standard 4-neighbor and 8-neighbor discrete kernels:

  • Property: Kernel coefficients sum to 0 (). Flat, uniform areas map to zero output (black). Zero-crossings mark edge transitions.

2. Sobel Operators (1st-order differential gradient)

Compute horizontal and vertical gradient components: Edge Magnitude:
Edge Direction:

3. Unsharp Masking

Subtracts a blurred version of the image to isolate high frequencies, then adds them back with a scaling factor :

  1. Blur image:
  2. Obtain high-frequency mask:
  3. Add back:
    • : Standard unsharp masking.
    • : Highboost filtering.

3. Separable Filters (Algorithmic Complexity Optimization)

A 2D spatial convolution kernel of size is defined as separable if it can be factored into the outer product of two 1D vectors:

Condition: The matrix must be rank 1.

   2D Kernel K (3x3):                     1D Vertical       1D Horizontal
   1/16 * [ 1  2  1 ]                         [ 1 ]
          [ 2  4  2 ]     =======>     1/4 *  [ 2 ]   *   1/4 * [ 1  2  1 ]
          [ 1  2  1 ]                         [ 1 ]

Computational Complexity Analysis

Let the target image have dimensions , and the square kernel have dimensions .

  • Standard 2D Convolution: For each of the pixels, we perform multiplications and additions.
  • Separable 2D Convolution: First, convolve every row with the 1D horizontal kernel ( multiplications per pixel). Then convolve the resulting matrix columns with the 1D vertical kernel ( multiplications per pixel).

Speedup Ratio:

Exam calculation: For a typical Gaussian smoothing kernel (): The Gaussian filter is mathematically separable because:


4. Non-Linear Spatial Filters

Non-linear filters do not satisfy the superposition principle: .

1. Median Filter

  • Operation: Slides a window over the image, extracts all pixel values within the neighborhood, sorts them in numerical order, and sets the center pixel to the median value:
  • Application: Standard method for removing Salt-and-Pepper (impulse) noise.
  • Comparison with Linear LPF: A linear mean filter averages impulse noise spikes ( or ) into adjacent pixels, blurring the noise without fully removing it. The median filter discards outliers because extreme values fall at the tail ends of the sorted sequence. It also preserves crisp step edges far better than a box or Gaussian filter.
Local 3x3 Window with "Salt" Noise:
[ 12  15  14 ]
[ 11 255  13 ]   ==> Sort: [11, 12, 12, 13, 14, 15, 16, 17, 255]
[ 12  16  17 ]   ==> Median = 14
                     The noise value (255) is completely eliminated!

2. Mode Filter

  • Operation: Replaces the central pixel with the most frequently occurring value within the neighborhood.
  • Application: Applied to classified labels, semantic segmentation masks, and indexed categorical maps to remove isolated misclassified noise pixels. It is not typically suited for continuous natural photographic images where neighboring pixel values vary continuously.

3. Bilateral Filter

  • Operation: An edge-preserving smoothing filter. While a standard Gaussian filter averages neighboring pixels based solely on their spatial distance, the bilateral filter introduces a second weight based on radiometric (intensity) similarity:

Where normalization factor is: And the spatial and range kernels are both Gaussians:

        Spatial Weight gs                 Range Weight gr (Edge Present)
         (Closer is higher)               (Similar intensity is higher)
             /\                                    |
            /  \                                   |        /---\
           /    \                                  |       /     \
      ----+------+----                       ------+------+-------+----
             p                                    I(p)          I(q) (Large delta I)
                                                  gr falls to ~0!
  • Mechanism at an Edge:
    • In flat, uniform regions, . The bilateral filter behaves identically to a standard Gaussian blur, smoothing out noise.
    • Across a sharp boundary, is large . The filter zeros out the contribution of pixels across the edge, smoothing strictly along the boundary rather than across it.
  • Application: Removing photographic grain/noise without blurring object outlines; surface normal smoothing; computational photography tone mapping.

Comprehensive Exam Review Cheat-Sheet

TopicCore Mathematical Formula / RuleKey Engineering Trade-off / Pitfall
Thin LensReal image (, behind lens) vs. Virtual image (, cannot capture on sensor).
Exposure / DOF, Small (wide aperture) shallow DOF, more light. Large deep DOF, less light.
SamplingSubsampling below Nyquist rate causes high frequencies to fold into low frequencies (Moiré).
Bit-PlanesMSB () preserves high-level structure; LSB () is noise-like and fragile to compression.
Histogram Eq.Fully automated global contrast expansion; can over-amplify background sensor noise.
IQA: SSIMQuantifies perceptual structure; outmatches MSE/RMSE on shifted or human-evaluated imagery.
Color: HSISeparates chromatic content from illumination; robust against shadows in segmentation.
Filter SeparationDrops 2D convolution execution time from to operations per pixel.
Median FilterHighly effective at suppressing salt-and-pepper noise while preserving sharp boundaries.
Bilateral FilterEdge-preserving smoothing; stops blur from leaking across steep intensity boundaries.