Deleting FAST files

This commit is contained in:
Ankit Agrawal
2013-11-29 20:37:25 +01:00
committed by Johannes Schönberger
parent 0b3414f057
commit 967524b71e
2 changed files with 0 additions and 146 deletions
-50
View File
@@ -1,50 +0,0 @@
import numpy as np
from scipy.ndimage.filters import maximum_filter
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 : int
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 w.r.t. 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_response = _corner_fast(image, n, threshold)
# 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)
corners = np.squeeze(np.dstack((x, y)))
return corners
-96
View File
@@ -1,96 +0,0 @@
#cython: cdivision=True
#cython: boundscheck=False
#cython: nonecheck=False
#cython: wraparound=False
import numpy as np
def _corner_fast(double[:, ::1] image, int n, double threshold):
cdef int[:] rp = (np.round(3 * np.sin(2 * np.pi * np.arange(16, dtype=np.double) / 16))).astype(np.int32)
cdef int[:] cp = (np.round(3 * np.cos(2 * np.pi * np.arange(16, dtype=np.double) / 16))).astype(np.int32)
cdef Py_ssize_t rows = image.shape[0]
cdef Py_ssize_t cols = image.shape[1]
cdef Py_ssize_t i, j, k, l, m
cdef char[:] bins = np.zeros(16, dtype=np.uint8)
cdef int consecutive_count, speed_sum_b, speed_sum_d
cdef int sp
cdef double sum_b, sum_d, current_pixel
cdef double[:, ::1] corner_response = np.zeros((rows, cols), dtype=np.double)
cdef double circle_intensity
for i in range(3, rows - 3):
for j in range(3, cols - 3):
current_pixel = image[i, j]
speed_sum_b = 0
speed_sum_d = 0
sum_b = 0
sum_d = 0
for k in range(16):
circle_intensity = image[i + rp[k], j + cp[k]]
if circle_intensity > current_pixel + threshold:
# Brighter pixel
bins[k] = 'b'
elif circle_intensity < current_pixel - threshold:
# Darker pixel
bins[k] = 'd'
else:
# Similar pixel
bins[k] = 's'
# High speed test for n>=12
if n >= 12:
for k in range(0, 16, 4):
if bins[k] == 'b':
speed_sum_b += 1
elif bins[k] == 'd':
speed_sum_d += 1
if speed_sum_d < 3 and speed_sum_b < 3:
continue
consecutive_count = 0
for l in range(15 + n):
if bins[l % 16] == 'b':
consecutive_count += 1
if consecutive_count == n:
for m in range(16):
if bins[m] == 'b':
sum_b += image[i + rp[m], j + cp[m]] - current_pixel - threshold
elif bins[m] == 'd':
sum_d += current_pixel - image[i + rp[m], j + cp[m]] - threshold
# Finding the response of the corner
if sum_d > sum_b:
corner_response[i, j] = sum_d
else:
corner_response[i, j] = sum_b
break
else:
consecutive_count = 0
if corner_response[i, j] == 0:
consecutive_count = 0
for l in range(15 + n):
if bins[l % 16] == 'd':
consecutive_count += 1
if consecutive_count == n:
for m in range(16):
if bins[m] == 'b':
sum_b += image[i + rp[m], j + cp[m]] - current_pixel - threshold
elif bins[m] == 'd':
sum_d += current_pixel - image[i + rp[m], j + cp[m]] - threshold
# Finding the response of the corner
if sum_d > sum_b:
corner_response[i, j] = sum_d
else:
corner_response[i, j] = sum_b
break
else:
consecutive_count = 0
return np.asarray(corner_response)