skimage2.feature.structure_tensor#
- skimage2.feature.structure_tensor(image, sigma=1, mode='constant', cval=0, order='rc')[source]#
Compute structure tensor using sum of squared differences.
The (2-dimensional) structure tensor A is defined as:
A = [Arr Arc] [Arc Acc]
which is approximated by the weighted sum of squared differences in a local window around each pixel in the image. This formula can be extended to a larger number of dimensions (see [1]).
- Parameters:
- imagendarray
Input image.
- sigmafloat or array-like of float, optional
Standard deviation used for the Gaussian kernel, which is used as a weighting function for the local summation of squared differences. If sigma is an iterable, its length must be equal to
image.ndimand each element is used for the Gaussian kernel applied along its respective axis.- mode{‘constant’, ‘reflect’, ‘wrap’, ‘nearest’, ‘mirror’}, optional
How to handle values outside the image borders.
- cvalfloat, optional
Used in conjunction with mode ‘constant’, the value outside the image boundaries.
- order{‘rc’, ‘xy’}, optional
NOTE: ‘xy’ is only an option for 2D images, higher dimensions must always use ‘rc’ order. This parameter allows for the use of reverse or forward order of the image axes in gradient computation. ‘rc’ indicates the use of the first axis initially (Arr, Arc, Acc), whilst ‘xy’ indicates the usage of the last axis initially (Axx, Axy, Ayy).
- Returns:
- A_elemslist of ndarray
Upper-diagonal elements of the structure tensor for each pixel in the input image.
See also
References
Examples
>>> from _skimage2.feature import structure_tensor >>> square = np.zeros((5, 5)) >>> square[2, 2] = 1 >>> Arr, Arc, Acc = structure_tensor(square, sigma=0.1, order='rc') >>> Acc array([[0., 0., 0., 0., 0.], [0., 1., 0., 1., 0.], [0., 4., 0., 4., 0.], [0., 1., 0., 1., 0.], [0., 0., 0., 0., 0.]])