niftynet.layer.spatial_gradient module¶
-
class
SpatialGradientLayer(spatial_axis=0, do_cropping=True, name='spatial_gradient')[source]¶ Bases:
niftynet.layer.base_layer.LayerComputing image spatial gradients.
-
layer_op(input_tensor)[source]¶ Computing spatial gradient of
input_tensoralongself.spatial_axis.- output is equivalent to convolve along
spatial_axiswith a - kernel:
[-1, 0, 1]
This layer assumes the first and the last dimension of the input tensor represent batch and feature channels. Therefore
spatial_axis=1is computing gradient along the third dimension of input tensor, i.e.,input_tensor[:, :, y, ...]Given the input with shape
[B, X, Y, Z, C], andspatial_axis=1the output shape is:[B, X-2, Y-2, Z-2, C] if do_scropping is True [B, X, Y-2, Z, C] otherwise
Setting do_cropping to True makes the output tensor has the same dimensionality for different
spatial_axis.Parameters: input_tensor – a batch of images with a shape of [Batch, x[, y, z, ... ], Channel]Returns: spatial gradients of input_tensor- output is equivalent to convolve along
-