--Output Using Algorithm 2 This algorithm detects shapes in images using the Generalized Hough Transform. It involves several steps including edge detection, gradient orientation computation, and gradient accumulation.
- Canny Edge Detection:
- Uses the
canny
function to detect edges in the image, effective for identifying boundaries.
- Uses the
- Gradient Orientation Calculation:
- Computes gradient orientation using the Sobel filter, with gradients calculated in both x and y directions (
dx
anddy
).
- Computes gradient orientation using the Sobel filter, with gradients calculated in both x and y directions (
- Building the R-Table:
- Constructs an R-Table based on detected edges and their gradient orientations. It stores relative positions (vectors) of edge points with respect to a reference point.
- Accumulate Gradients Using R-Table:
- Uses the R-Table to accumulate votes in an accumulator array. For each edge point, the function looks up corresponding vectors and increments the accumulator.
- Overlay the Reference Image:
- The
overlay_reference_image
function overlays the reference image on the query image at the detected position.
- The
- Visualization:
- The
test_general_hough
function visualizes the results including the reference image, query image with detected points, the accumulator, and the final overlay.
- The
- Shape-to-Image Conversion:
- Converts a set of shapes into binary images using the
shapes_to_image
function.
- Converts a set of shapes into binary images using the
- Testing:
- The
test
function reads shape data from CSV files, converts them to images, and applies the Generalized Hough Transform.
- The
-
Read and Convert Shape Data:
- Read shape data from CSV files and convert them to binary images.
-
Apply Generalized Hough Transform:
- Apply the Generalized Hough Transform to the query image using the reference images.
-
Visualize Results:
- Visualize the results including the best match and the overlayed reference image.
- Edge Detection: Uses Canny edge detection and Sobel filter.
- R-Table Construction: Creates a lookup table for edge points.
- Gradient Accumulation: Accumulates votes in an accumulator array.
- Overlay and Visualization: Displays detected shapes and overlays the reference image..