📘
Edge Count Heuristic
EasyEarly Vision
Implement a simple edge detection technique to count the number of edges in a grayscale image. This task involves applying a basic heuristic to identify pixels with significant intensity changes.
The concept of edge detection is crucial in computer vision as it helps in identifying boundaries and structures within an image. A grayscale image can be represented as a 2D array of intensity values, where each pixel's value is a scalar between 0 and 255. The absolute difference between neighboring pixels can be used to determine the presence of an edge.
To detect edges, follow these steps:
- Iterate over each pixel in the image, excluding border pixels.
- For each pixel, calculate the absolute difference with its 4-neighbors.
- If any of these differences exceed a given threshold, mark the pixel as an edge.
This technique is widely used in image processing applications.
Example:
Input:
count_edges([[0,0,100],[0,0,100],[0,0,100]], 50)
Output:
3
Reasoning:
Middle column pixels have neighbors differing by 100 > 50
Constraints:
- Image is a 2D grayscale array
- Threshold is a positive integer
- Don't count border pixels as edges
- Return total count of edge pixels
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.