mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 21:08:24 +08:00
Add functions to compute eigen values of structure tensor and hessian matrix
This commit is contained in:
@@ -5,7 +5,8 @@ from .peak import peak_local_max
|
||||
from .corner import (corner_kitchen_rosenfeld, corner_harris,
|
||||
corner_shi_tomasi, corner_foerstner, corner_subpix,
|
||||
corner_peaks, corner_fast, structure_tensor,
|
||||
hessian_matrix)
|
||||
structure_tensor_eigvals, hessian_matrix,
|
||||
hessian_matrix_eigvals)
|
||||
from .corner_cy import corner_moravec, corner_orientations
|
||||
from .template import match_template
|
||||
from ._brief import brief, match_keypoints_brief
|
||||
@@ -33,4 +34,6 @@ __all__ = ['daisy',
|
||||
'corner_fast',
|
||||
'corner_orientations',
|
||||
'structure_tensor',
|
||||
'hessian_matrix']
|
||||
'structure_tensor_eigvals',
|
||||
'hessian_matrix',
|
||||
'hessian_matrix_eigvals']
|
||||
|
||||
@@ -147,6 +147,86 @@ def hessian_matrix(image, sigma=1, mode='constant', cval=0):
|
||||
return Hxx, Hxy, Hyy
|
||||
|
||||
|
||||
def _image_orthogonal_matrix22_eigvals(M00, M01, M11):
|
||||
l1 = (M00 + M11) / 2 + np.sqrt(4 * M01 ** 2 + (M00 - M11) ** 2) / 2
|
||||
l2 = (M00 + M11) / 2 - np.sqrt(4 * M01 ** 2 + (M00 - M11) ** 2) / 2
|
||||
return l1, l2
|
||||
|
||||
|
||||
def structure_tensor_eigvals(Axx, Axy, Ayy):
|
||||
"""Compute Eigen values of structure tensor.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
Axx : ndarray
|
||||
Element of the structure tensor for each pixel in the input image.
|
||||
Axy : ndarray
|
||||
Element of the structure tensor for each pixel in the input image.
|
||||
Ayy : ndarray
|
||||
Element of the structure tensor for each pixel in the input image.
|
||||
|
||||
Returns
|
||||
-------
|
||||
l1 : ndarray
|
||||
Larger eigen value for each input matrix.
|
||||
l2 : ndarray
|
||||
Smaller eigen value for each input matrix.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.feature import structure_tensor, structure_tensor_eigvals
|
||||
>>> square = np.zeros((5, 5))
|
||||
>>> square[2, 2] = 1
|
||||
>>> Axx, Axy, Ayy = structure_tensor(square, sigma=0.1)
|
||||
>>> structure_tensor_eigvals(Axx, Axy, Ayy)[0]
|
||||
array([[ 0., 0., 0., 0., 0.],
|
||||
[ 0., 2., 4., 2., 0.],
|
||||
[ 0., 4., 0., 4., 0.],
|
||||
[ 0., 2., 4., 2., 0.],
|
||||
[ 0., 0., 0., 0., 0.]])
|
||||
|
||||
"""
|
||||
|
||||
return _image_orthogonal_matrix22_eigvals(Axx, Axy, Ayy)
|
||||
|
||||
|
||||
def hessian_matrix_eigvals(Hxx, Hxy, Hyy):
|
||||
"""Compute Eigen values of Hessian matrix.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
Hxx : ndarray
|
||||
Element of the Hessian matrix for each pixel in the input image.
|
||||
Hxy : ndarray
|
||||
Element of the Hessian matrix for each pixel in the input image.
|
||||
Hyy : ndarray
|
||||
Element of the Hessian matrix for each pixel in the input image.
|
||||
|
||||
Returns
|
||||
-------
|
||||
l1 : ndarray
|
||||
Larger eigen value for each input matrix.
|
||||
l2 : ndarray
|
||||
Smaller eigen value for each input matrix.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.feature import hessian_matrix, hessian_matrix_eigvals
|
||||
>>> square = np.zeros((5, 5))
|
||||
>>> square[2, 2] = 1
|
||||
>>> Hxx, Hxy, Hyy = hessian_matrix(square, sigma=0.1)
|
||||
>>> hessian_matrix_eigvals(Hxx, Hxy, Hyy)[0]
|
||||
array([[ 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 1., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0.]])
|
||||
|
||||
"""
|
||||
|
||||
return _image_orthogonal_matrix22_eigvals(Hyy, Hxy, Hyy)
|
||||
|
||||
|
||||
def corner_kitchen_rosenfeld(image, mode='constant', cval=0):
|
||||
"""Compute Kitchen and Rosenfeld corner measure response image.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user