mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-11 12:43:04 +08:00
Adding docstrings and commenting the code
This commit is contained in:
committed by
Johannes Schönberger
parent
6b3751a52f
commit
94e4a88712
+34
-6
@@ -6,17 +6,45 @@ from fast_cy import _corner_fast
|
||||
|
||||
def corner_fast(image, n=12, threshold=0.15):
|
||||
|
||||
"""Extract FAST corners for a given image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : 2D ndarray
|
||||
Input image.
|
||||
n : integer
|
||||
Number of consecutive pixels out of 16 pixels on the circle that
|
||||
should be brighter or darker with respect to test pixel above the
|
||||
`threshold` so as to classify the test pixel as a FAST corner. Also
|
||||
stands for the n in `FAST-n` corner detector.
|
||||
threshold : float
|
||||
Threshold used in deciding whether the pixels on the circle are
|
||||
brighter, darker or similar to the test pixel. Decrease the threshold
|
||||
when more corners are desired and vice-versa.
|
||||
|
||||
Returns
|
||||
-------
|
||||
corners : (N, 2) ndarray
|
||||
Location i.e. (row, col) of extracted FAST corners.
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] Edward Rosten and Tom Drummond
|
||||
"Machine Learning for high-speed corner detection",
|
||||
http://www.edwardrosten.com/work/rosten_2006_machine.pdf
|
||||
|
||||
"""
|
||||
image = np.squeeze(image)
|
||||
if image.ndim != 2:
|
||||
raise ValueError("Only 2-D gray-scale images supported.")
|
||||
|
||||
image = np.ascontiguousarray(image, dtype=np.double)
|
||||
corner = _corner_fast(image, n, threshold)
|
||||
corner_response = _corner_fast(image, n, threshold)
|
||||
|
||||
corner_zero_mask = corner != 0
|
||||
c, d = np.nonzero(corner)
|
||||
|
||||
maximas = (maximum_filter(corner, (3, 3)) == corner) & corner_zero_mask
|
||||
# Non-maximal Suppression
|
||||
corner_zero_mask = corner_response != 0
|
||||
maximas = (maximum_filter(corner_response, (3, 3)) == corner_response) & corner_zero_mask
|
||||
x, y = np.where(maximas == True)
|
||||
|
||||
return np.squeeze(np.dstack((x, y)))
|
||||
corners = np.squeeze(np.dstack((x, y)))
|
||||
return corners
|
||||
|
||||
Reference in New Issue
Block a user