gradient

menpo.feature.gradient(image, *args, **kwargs)[source]

Calculates the gradient of an input image. The image is assumed to have channel information on the last axis. In the case of multiple channels, it returns the gradient over each axis over each channel as the last axis.

Parameters:pixels (Image or subclass or (X, Y, ..., Z, C) ndarray) – Either the image object itself or an array with the pixels. The last dimension is interpreted as channels. This means an N-dimensional image is represented by an N+1 dimensional array.
Returns:gradient (ndarray, shape (X, Y, ..., Z, C * length([X, Y, ..., Z]))) – The gradient over each axis over each channel. Therefore, the last axis of the gradient of a 2D, single channel image, will have length 2. The last axis of the gradient of a 2D, 3-channel image, will have length 6, he ordering being [Rd_x, Rd_y, Gd_x, Gd_y, Bd_x, Bd_y].