Rename corner operators and file

This commit is contained in:
Johannes Schönberger
2012-09-11 18:58:45 +02:00
parent 3b9ffe1cd8
commit 16f09d358d
5 changed files with 23 additions and 22 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
from ._hog import hog
from .texture import greycomatrix, greycoprops, local_binary_pattern
from .peak import peak_local_max
from .interest import harris, shi_tomasi
from .interest_cy import moravec
from .corner import corner_harris, corner_shi_tomasi
from .corner_cy import corner_moravec
from .template import match_template
@@ -40,7 +40,7 @@ def _compute_auto_correlation(image, sigma):
return Axx, Axy, Ayy
def harris(image, method='k', k=0.05, eps=1e-6, sigma=1):
def corner_harris(image, method='k', k=0.05, eps=1e-6, sigma=1):
"""Compute Harris response image.
This corner detector uses information in the auto-correlation matrix
@@ -110,7 +110,7 @@ def harris(image, method='k', k=0.05, eps=1e-6, sigma=1):
return response
def shi_tomasi(image, sigma=1):
def corner_shi_tomasi(image, sigma=1):
"""Compute Shi-Tomasi (Kanade-Tomasi) response image.
This corner detector uses information in the auto-correlation matrix
@@ -10,7 +10,7 @@ from skimage.color import rgb2grey
from skimage.util import img_as_float
def moravec(image, int window_size=1):
def corner_moravec(image, int window_size=1):
"""Compute Moravec response image.
This interest operator is comparatively fast but not rotation invariant.
+2 -2
View File
@@ -12,11 +12,11 @@ def configuration(parent_package='', top_path=None):
config = Configuration('feature', parent_package, top_path)
config.add_data_dir('tests')
cython(['interest_cy.pyx'], working_path=base_path)
cython(['corner_cy.pyx'], working_path=base_path)
cython(['_texture.pyx'], working_path=base_path)
cython(['_template.pyx'], working_path=base_path)
config.add_extension('interest_cy', sources=['interest_cy.c'],
config.add_extension('corner_cy', sources=['corner_cy.c'],
include_dirs=[get_numpy_include_dirs()])
config.add_extension('_texture', sources=['_texture.c'],
include_dirs=[get_numpy_include_dirs(), '../_shared'])
@@ -3,7 +3,8 @@ import numpy as np
from skimage import data
from skimage import img_as_float
from skimage.feature import moravec, harris, shi_tomasi, peak_local_max
from skimage.feature import (corner_moravec, corner_harris, corner_shi_tomasi,
peak_local_max)
def test_square_image():
@@ -11,17 +12,17 @@ def test_square_image():
im[:25, :25] = 1.
# Moravec
results = peak_local_max(moravec(im))
results = peak_local_max(corner_moravec(im))
# interest points along edge
assert len(results) == 57
# Harris
results = peak_local_max(harris(im))
results = peak_local_max(corner_harris(im))
# interest at corner
assert len(results) == 1
# Shi-Tomasi
results = peak_local_max(shi_tomasi(im))
results = peak_local_max(corner_shi_tomasi(im))
# interest at corner
assert len(results) == 1
@@ -32,16 +33,16 @@ def test_noisy_square_image():
im = im + np.random.uniform(size=im.shape) * .2
# Moravec
results = peak_local_max(moravec(im))
results = peak_local_max(corner_moravec(im))
# undefined number of interest points
assert results.any()
# Harris
results = peak_local_max(harris(im, sigma=1.5))
results = peak_local_max(corner_harris(im, sigma=1.5))
assert len(results) == 1
# Shi-Tomasi
results = peak_local_max(shi_tomasi(im, sigma=1.5))
results = peak_local_max(corner_shi_tomasi(im, sigma=1.5))
assert len(results) == 1
@@ -53,11 +54,11 @@ def test_squared_dot():
# Moravec fails
# Harris
results = peak_local_max(harris(im))
results = peak_local_max(corner_harris(im))
assert (results == np.array([[6, 6]])).all()
# Shi-Tomasi
results = peak_local_max(shi_tomasi(im))
results = peak_local_max(corner_shi_tomasi(im))
assert (results == np.array([[6, 6]])).all()
@@ -70,20 +71,20 @@ def test_rotated_lena():
im_rotated = im.T
# Moravec
results = peak_local_max(moravec(im))
results_rotated = peak_local_max(moravec(im_rotated))
results = peak_local_max(corner_moravec(im))
results_rotated = peak_local_max(corner_moravec(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Harris
results = peak_local_max(harris(im))
results_rotated = peak_local_max(harris(im_rotated))
results = peak_local_max(corner_harris(im))
results_rotated = peak_local_max(corner_harris(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Shi-Tomasi
results = peak_local_max(shi_tomasi(im))
results_rotated = peak_local_max(shi_tomasi(im_rotated))
results = peak_local_max(corner_shi_tomasi(im))
results_rotated = peak_local_max(corner_shi_tomasi(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()