While the first half focused on finding local discontinuities (points, lines, and edges), this half shifts to piecing those local features into global shapes and grouping pixels based on similarity.


1. Global Processing: The Hough Transform

Local edge linking (like the neighborhood magnitude/angle checks we did previously) can sometimes struggle to connect fragmented edges into meaningful shapes. If the goal is to detect straight, continuous structures—like tracking lane boundaries for highway traffic analysis—we need a global perspective. The Hough Transform is a technique used to find edge points that lie along a specific mathematical shape, most commonly straight lines.

The Mathematical Concept

Instead of looking at the image in the standard Cartesian xy-plane, the Hough Transform maps points into a "Parameter Space".

Initially, you might think to use the standard line equation y=ax+b to map to an ab-plane. However, vertical lines have an infinite slope (a=), which breaks the math. To solve this, the algorithm uses a polar coordinate representation:

xcosθ+ysinθ=ρ

The Accumulator Algorithm

  1. Initialize: Create a 2D matrix (an accumulator array) where the rows represent quantized values of ρ and columns represent quantized values of θ. Set all cells to zero.

  2. Transform: For every edge pixel (xk,yk) found in your image, loop through every possible angle θ and calculate the resulting ρ using the polar equation.

  3. Vote: Round ρ to the nearest index and increment that (ρ,θ) cell in the accumulator by 1.

  4. Extract: A single point in the xy-plane becomes a sinusoidal curve in the ρθ-plane. When multiple curves intersect at the exact same (ρ,θ) cell, it creates a "peak" in the accumulator. This peak represents a strong line in the original image.

The goal of this example is to take a binary image containing edge pixels and map them into the Hough parameter space (ρ,θ) to detect straight lines.

Pasted image 20260511170342.png

1. Setting Up the Image and Coordinate System

The example begins with a 4×5 binary image matrix where the 1s represent detected edge pixels.

2. Parameter Space Quantization

To create the 2D accumulator array, the continuous parameters ρ and θ must be quantized into discrete bins.

This creates a 6×5 accumulator matrix initialized with zeros.

3. The Accumulation Process (The Math)

For every edge pixel (x,y), the algorithm loops through every quantized θ value, calculates ρ using the equation ρ=xcos(θ)+ysin(θ) , rounds ρ to the nearest integer , and increments that cell in the accumulator.

Processing the First Edge Point: (0,2)

Processing the Second Edge Point: (0,3)

Note: As this process repeats for the remaining pixels (1,3), (2,3), and (3,4), the accumulator grid fills up, representing the number of sinusoidal curves intersecting at those specific parameter bins.

Pasted image 20260511183436.png

4. Thresholding to Find Lines

Once the accumulator is fully populated, a threshold is applied to find the strongest lines. The slides specify a threshold of 3. Any value in the final matrix where the intersection count is 3 is set to 1 (indicating a valid line), and everything else is set to 0.

(Note: The slides explicitly state that the final 6×5 matrix shown on slide 17 is "not accurate for the given example" and is instead a conceptual placeholder to demonstrate how the final thresholding step converts a high-value accumulator into a binary output ).

Note: This same principle can be adapted for circle detection by expanding the parameter space to 3D to account for the circle equation (xia)2+(yib)2=r2 where the parameters are (a,b,r).


2. Region-Based Segmentation (Similarity)

When edges are too noisy or disconnected, finding boundaries fails. Region-based segmentation takes the opposite approach: it groups pixels together that share similar attributes (like intensity, color, or texture).

Simple Global Thresholding

This is the most basic form of segmentation. If you have light objects on a dark background, you separate them by choosing a threshold T.

Automatic Threshold Calculation: Instead of guessing T, an algorithm can compute it automatically using the image's histogram:

  1. Compute the average gray level (μ1) for pixels in the background and the average gray level (μ2) for pixels in the object.

  2. Set the threshold exactly in the middle: T=μ1+μ22.

  3. Apply this threshold to create the binary image.

Region Growing

When simple thresholding fails (e.g., due to uneven lighting or severe noise), Region Growing is used.

  1. Seed Selection: The algorithm starts with a set of specific starting pixels called "seed" points.

  2. Aggregation: It looks at the neighboring pixels around the seed. If the absolute difference between the neighbor's gray level and the seed's gray level falls within a strict similarity threshold, that neighbor is "appended" to the growing region.

  3. Iteration: This process spreads outward like a puddle until no more adjacent pixels meet the similarity criteria.