sobel

sofia_redux.toolkit.convolve.filter.sobel(input_array, kderiv=(-1, 0, 1), kperp=(1, 2, 1), pnorm=1, doabs=True, axis=None, mode='reflect', cval=0.0, origin=0)[source]

Edge enhancement Sobel filter for n-dimensional images.

Applies a Sobel filter over each dimension and returns the p-norm (default=1). When calculating G_i for dimension i, the convolution kernel will be formed from a convolution of kaxis along dimension i, and kother along all remaining dimensions.

Parameters:
input_arrayarray_like of (int or float)

(shape) in n-features

kderivarray, optional

The kernel operator in the derivate direction.

kperparray, optional

The kernel operator perpendicular to the derivative direction.

pnormint or float, optional

If axis is None, ‘p’ value of the p-norm applied to the addition of convolution results over each axis.

doabsbool, optional

If True, and axis=None, the absolute value of the result for each axis will be taken when calculating the p-norm for the final result.

axisint, optional

If provided, the sobel filter will only be applied over this axis. Otherwise, the results for each axis will be combined according to pnorm and doabs.

mode{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional

The mode parameter determines how the input array is extended beyond its boundaries. Default is ‘reflect’. Behavior for each valid value is as follows:

‘reflect’ (d c b a | a b c d | d c b a)

The input is extended by reflecting about the edge of the last pixel.

‘constant’ (k k k k | a b c d | k k k k)

The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter.

‘nearest’ (a a a a | a b c d | d d d d)

The input is extended by replicating the last pixel.

‘mirror’ (d c b | a b c d | c b a)

The input is extended by reflecting about the center of the last pixel.

‘wrap’ (a b c d | a b c d | a b c d)

The input is extended by wrapping around to the opposite edge.

cvalscalar, optional

Value to fill past edges of input if mode is ‘constant’. Default is 0.0.

originint, optional

Controls the placement of the filter on the input array’s pixels. A value of 0 (the default) centers the filter over the pixel, with positive values shifting the filter to the left, and negative ones to the right.

Returns:
edgesnumpy.ndarray

(shape) of the same type as image.