PIXELBANKv9.1.0
Menu

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:

  1. Get the intensity of all 16 circle pixels
  2. Check if N or more contiguous pixels are all brighter than center + threshold
  3. OR check if N or more contiguous pixels are all darker than center - threshold
  4. If either condition is met, it's a corner

Note: The circle wraps around (position 15 is contiguous with position 0).

Example:

Input:
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
Output:
[(3, 3)]
Reasoning:

Checking pixel (3,3) with intensity 200:

Circle pixels around (3,3) all have intensity 50.

  • Checking for N=12 contiguous darker pixels:
    • Each circle pixel (50) is 50 - 200 = -150 less than center
    • Since 50 < 200 - 40 = 160, all 16 pixels are "darker"
    • We need 12 contiguous darker pixels
    • All 16 are darker, so we have 16 ≥ 12 contiguous darker pixels ✓

Result: (3,3) is a corner because the center is much brighter than its surroundings.

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)
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
FAST Corner Detector (Simplified) - Hard | PixelBank