FAST Corner Detector (Simplified)
Implement a simplified version of the FAST (Features from Accelerated Segment Test) corner detector.
FAST detects corners by examining pixels on a circle around each candidate point. A point is a corner if a sufficient number of contiguous pixels on the circle are all brighter (or all darker) than the center by at least a threshold.
The algorithm uses a circle of 16 pixels at radius 3:
- Positions: (-3,0), (-3,1), (-2,2), (-1,3), (0,3), (1,3), (2,2), (3,1), (3,0), (3,-1), (2,-2), (1,-3), (0,-3), (-1,-3), (-2,-2), (-3,-1)
For each pixel:
- Get the intensity of all 16 circle pixels
- Check if N or more contiguous pixels are all brighter than center + threshold
- OR check if N or more contiguous pixels are all darker than center - threshold
- If either condition is met, it's a corner
Note: The circle wraps around (position 15 is contiguous with position 0).
Example
image = [[50,50,50,50,50,50,50],
[50,50,50,50,50,50,50],
[50,50,50,50,50,50,50],
[50,50,50,200,50,50,50],
[50,50,50,50,50,50,50],
[50,50,50,50,50,50,50],
[50,50,50,50,50,50,50]]
threshold = 40
n = 12[(3, 3)]
- Inputs:
imageis a grid, all except one pixel of at row , column .thresholdis the required gap, andnis the run length needed. - Which centres qualify: a radius-3 circle only fits when both row and column lie in , so is the one and only candidate in this image.
- Bright and dark bands: with centre , a circle pixel counts as brighter if and darker if .
- The circle: all 16 offsets land on pixels of value . None exceed , but every one satisfies , so the darker run has length . The centre is a corner.
- Output:
[(3, 3)], a list of (row, col) pairs. - Notice: both inequalities are strict. With
thresholdthe dark band would need , and is false, so the same image would return[].
Constraints
- image is a 2D grayscale image (integer values)
- threshold is the intensity difference required
- n is the number of contiguous pixels required (default 12)
- Return list of (row, col) corner coordinates
- Only check pixels where a full circle fits (row and col >= 3 and < size-3)