mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-12 07:12:31 +08:00
Move FAST corner function to other corner functions
This commit is contained in:
+67
-67
@@ -329,6 +329,73 @@ def corner_foerstner(image, sigma=1):
|
||||
return w, q
|
||||
|
||||
|
||||
def corner_fast(image, n=12, threshold=0.15):
|
||||
|
||||
"""Extract FAST corners for a given image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : 2D ndarray
|
||||
Input image.
|
||||
n : int
|
||||
Minimum number of consecutive pixels out of 16 pixels on the circle
|
||||
that should all be either brighter or darker w.r.t testpixel.
|
||||
A point c on the circle is darker w.r.t test pixel p if
|
||||
`Ic < Ip - threshold` and brighter if `Ic > Ip + threshold`. 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 w.r.t. the test pixel. Decrease the
|
||||
threshold when more corners are desired and vice-versa.
|
||||
|
||||
Returns
|
||||
-------
|
||||
response : ndarray
|
||||
FAST corner response image.
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] Edward Rosten and Tom Drummond
|
||||
"Machine Learning for high-speed corner detection",
|
||||
http://www.edwardrosten.com/work/rosten_2006_machine.pdf
|
||||
.. [2] Wikipedia, "Features from accelerated segment test",
|
||||
https://en.wikipedia.org/wiki/Features_from_accelerated_segment_test
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.feature import corner_fast, corner_peaks
|
||||
>>> square = np.zeros((12, 12))
|
||||
>>> square[3:9, 3:9] = 1
|
||||
>>> square
|
||||
array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
|
||||
>>> corner_peaks(corner_fast(square, 9), min_distance=1)
|
||||
array([[3, 3],
|
||||
[3, 8],
|
||||
[8, 3],
|
||||
[8, 8]])
|
||||
|
||||
"""
|
||||
image = np.squeeze(image)
|
||||
if image.ndim != 2:
|
||||
raise ValueError("Only 2-D gray-scale images supported.")
|
||||
|
||||
image = img_as_float(image)
|
||||
image = np.ascontiguousarray(image)
|
||||
response = _corner_fast(image, n, threshold)
|
||||
return response
|
||||
|
||||
|
||||
def corner_subpix(image, corners, window_size=11, alpha=0.99):
|
||||
"""Determine subpixel position of corners.
|
||||
|
||||
@@ -545,70 +612,3 @@ def corner_peaks(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
|
||||
return np.transpose(peaks.nonzero())
|
||||
else:
|
||||
return peaks
|
||||
|
||||
|
||||
def corner_fast(image, n=12, threshold=0.15):
|
||||
|
||||
"""Extract FAST corners for a given image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : 2D ndarray
|
||||
Input image.
|
||||
n : int
|
||||
Minimum number of consecutive pixels out of 16 pixels on the circle
|
||||
that should all be either brighter or darker w.r.t testpixel.
|
||||
A point c on the circle is darker w.r.t test pixel p if
|
||||
`Ic < Ip - threshold` and brighter if `Ic > Ip + threshold`. 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 w.r.t. the test pixel. Decrease the
|
||||
threshold when more corners are desired and vice-versa.
|
||||
|
||||
Returns
|
||||
-------
|
||||
response : ndarray
|
||||
FAST corner response image.
|
||||
|
||||
References
|
||||
----------
|
||||
.. [1] Edward Rosten and Tom Drummond
|
||||
"Machine Learning for high-speed corner detection",
|
||||
http://www.edwardrosten.com/work/rosten_2006_machine.pdf
|
||||
.. [2] Wikipedia, "Features from accelerated segment test",
|
||||
https://en.wikipedia.org/wiki/Features_from_accelerated_segment_test
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.feature import corner_fast, corner_peaks
|
||||
>>> square = np.zeros((12, 12))
|
||||
>>> square[3:9, 3:9] = 1
|
||||
>>> square
|
||||
array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 1., 1., 1., 1., 1., 1., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
|
||||
>>> corner_peaks(corner_fast(square, 9), min_distance=1)
|
||||
array([[3, 3],
|
||||
[3, 8],
|
||||
[8, 3],
|
||||
[8, 8]])
|
||||
|
||||
"""
|
||||
image = np.squeeze(image)
|
||||
if image.ndim != 2:
|
||||
raise ValueError("Only 2-D gray-scale images supported.")
|
||||
|
||||
image = img_as_float(image)
|
||||
image = np.ascontiguousarray(image)
|
||||
response = _corner_fast(image, n, threshold)
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user