tfmri.image.image_gradients
tfmri.image.image_gradients¶
- image_gradients(image, method='sobel', norm=False, batch_dims=None, image_dims=None, name=None)[source]¶
Computes image gradients.
Supports 2D and 3D inputs.
- Parameters
image – A tf.Tensor of shape
batch_shape + image_shape + [channels]. The number of dimensions inbatch_shapeandimage_shapecan be specified using the argumentsbatch_dimsandimage_dimsrespectively. By default, if neitherbatch_dimsnorimage_dimsare specified, it is assumed that there is one batch dimension, i.e. thatimagehas shape[batch_size] + image_shape + [channels].method – A str. The operator to use for gradient computation. Must be one of
'prewitt','sobel'or'scharr'. Defaults to'sobel'.batch_dims –
An int. The number of batch dimensions in
image. If None, it is inferred fromimageandimage_dimsasimage.shape.rank - image_dims - 1. Ifimage_dimsis also None, thenbatch_dimsdefaults to 1.batch_dimscan always be inferred ifimage_dimswas 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 fromimageandbatch_dimsasimage.shape.rank - batch_dims - 1. Defaults to None.image_dimscan always be inferred ifbatch_dimswas specified, so you only need to provide one of the two.name – A name for the operation (optional).
- Returns
A tf.Tensor of shape
image.shape + [len(spatial_dims)]holding the image gradients along each spatial dimension.