The function gradients_xy carries out Gaussian smoothing followed by differencing as a way of estimating the spatial gradients of a grey-level image in the X and Y directions. This is the initial stage of the well-known Canny edge detector, but the gradients can be used for many other applications.
The function offers independent control of the smoothing parameters.
Particular care is taken of how pixels close to the image boundaries are treated. By default, the output gradient arrays are smaller than the image so that only valid values need be computed, but an option allows them to be the same size as the image. Values close to the boundaries are then computed by extrapolation of the image using reflection or tiling.
The function gradients_xyt takes two images, and uses their average to estimate spatial gradients and their difference to estimate temporal gradients.
The function gsmooth2 carries out Gaussian smoothing, and the convenience function exindex simplifies extrapolation.