Canny Edge Detection
Multi-stage edge detection algorithm. Gaussian blur → gradient calculation → non-maximum suppression → hysteresis thresholding. Industry standard for edge detection.
Visualization
Interactive visualization for Canny Edge Detection
Canny Edge:
- • Multi-stage algorithm
Interactive visualization with step-by-step execution
Implementation
1// Simplified Canny Edge Detection
2function cannyEdgeDetection(image: number[][], lowThreshold: number, highThreshold: number): number[][] {
3 const height = image.length;
4 const width = image[0].length;
5
6 // 1. Gaussian blur (simplified)
7 const blurred = gaussianBlur(image, 5);
8
9 // 2. Calculate gradients
10 const { magnitude, direction } = calculateGradients(blurred);
11
12 // 3. Non-maximum suppression
13 const suppressed = nonMaxSuppression(magnitude, direction);
14
15 // 4. Double threshold
16 const edges = doubleThreshold(suppressed, lowThreshold, highThreshold);
17
18 // 5. Edge tracking
19 return edgeTrackingByHysteresis(edges);
20}Deep Dive
Theoretical Foundation
5 stages: 1) Gaussian blur (noise reduction), 2) Gradient intensity/direction (Sobel), 3) Non-maximum suppression (thin edges), 4) Double threshold (strong/weak edges), 5) Edge tracking by hysteresis.
Complexity
Time
O(w×h)
O(w×h)
O(w×h)
Space
O(w×h)
Applications
Industry Use
Autonomous vehicle lane detection
Medical image analysis (tumor boundaries)
Industrial quality control and inspection
Optical character recognition (OCR)
Robotics navigation and obstacle detection
Satellite image analysis
Augmented reality marker detection
Use Cases
Related Algorithms
A* Search Algorithm
Informed search algorithm combining best-first search with Dijkstra's algorithm using heuristics. Widely used in pathfinding and graph traversal, A* is optimal and complete when using admissible heuristic. Used in games, GPS navigation, and robotics. Invented by Peter Hart, Nils Nilsson, and Bertram Raphael in 1968.
Convex Hull (Graham Scan)
Find smallest convex polygon containing all points. Graham Scan invented by Ronald Graham in 1972, runs in O(n log n). Essential in computational geometry, computer graphics, and pattern recognition.
Line Segment Intersection
Determine if two line segments intersect. Fundamental geometric primitive used in graphics, CAD, GIS. Uses orientation and collinearity tests.
Caesar Cipher
The Caesar Cipher is one of the oldest and simplest encryption techniques, named after Julius Caesar who used it to protect military messages around 100 BC. It works by shifting each letter in the plaintext by a fixed number of positions down the alphabet. For example, with a shift of 3, A becomes D, B becomes E, and so on. Despite being used for over 2000 years, it's extremely weak by modern standards with only 25 possible keys, making it trivially breakable by brute force or frequency analysis.