tfmri.image.gradient_magnitude
tfmri.image.gradient_magnitude¶
- gradient_magnitude(image, method='sobel', norm=False, batch_dims=None, image_dims=None, name=None)[source]¶
Computes the gradient magnitude (GM) of an image.
Supports 2D and 3D inputs.
- Parameters
image – A tf.Tensor of shape
batch_shape + image_shape + [channels]
. The number of dimensions inbatch_shape
andimage_shape
can be specified using the argumentsbatch_dims
andimage_dims
respectively. By default, if neitherbatch_dims
norimage_dims
are specified, it is assumed that there is one batch dimension, i.e. thatimage
has shape[batch_size] + image_shape + [channels]
.method – The gradient operator to use. Can be
'prewitt'
,'sobel'
or'scharr'
. Defaults to'sobel'
.norm – A boolean. If True, returns the normalized gradient magnitude.
batch_dims –
An int. The number of batch dimensions in
image
. If None, it is inferred fromimage
andimage_dims
asimage.shape.rank - image_dims - 1
. Ifimage_dims
is also None, thenbatch_dims
defaults to 1.batch_dims
can always be inferred ifimage_dims
was specified, so you only need to provide one of the two.image_dims –
An int. The number of spatial dimensions in
image
. If None, it is inferred fromimage
andbatch_dims
asimage.shape.rank - batch_dims - 1
. Defaults to None.image_dims
can always be inferred ifbatch_dims
was specified, so you only need to provide one of the two.name – A name for the operation (optional).
- Returns
A tf.Tensor of the same shape and type as
image
holding the gradient magnitude of the input image.