nvidia.dali.fn.laplacian(*inputs, **kwargs)

Computes the Laplacian of an input.

The Laplacian is calculated as the sum of second order partial derivatives with respect to each spatial dimension. Each partial derivative is approximated with a separable convolution, that uses a derivative window in the direction of the partial derivative and smoothing windows in the remaining axes.

By default, each partial derivative is approximated by convolving along all spatial axes: the axis in partial derivative direction uses derivative window of window_size and the remaining axes are convolved with smoothing windows of the same size. If smoothing_size is specified, the smoothing windows applied to a given axis can have different size than the derivative window. Specifying smoothing_size = 1 implies no smoothing in axes perpendicular to the derivative direction.

Both window_size and smoothing_size can be specified as a single value or per axis. For example, for volumetric input, if window_size=[dz, dy, dx] and smoothing_size=[sz, sy, sx] are specified, the following windows will be used:

  • for partial derivative in z direction: derivative windows of size dz along z axis, and smoothing windows of size sy and sx along y and x respectively.

  • for partial derivative in y direction: derivative windows of size dy along y axis, and smoothing windows of size sz and sx along z and x respectively.

  • for partial derivative in x direction: derivative windows of size dx along x axis, and smoothing windows of size sz and sy along z and y respectively.

Window sizes and smoothing sizes must be odd. The size of a derivative window must be at least 3. Smoothing window can be of size 1, which implies no smoothing along corresponding axis.

To normalize partial derivatives, normalized_kernel=True can be used. Each partial derivative is scaled by 2^(-s + n + 2), where s is the sum of the window sizes used to calculate a given partial derivative (including the smoothing windows) and n is the number of data dimensions/axes. Alternatively, you can specify scale argument to customize scaling factors. Scale can be either a single value or n values, one for every partial derivative.

Operator uses 32-bit floats as an intermediate type.


The channel C and frame F dimensions are not considered data axes. If channels are present, only channel-first or channel-last inputs are supported.

This operator allows sequence inputs and supports volumetric data.

Supported backends
  • ‘cpu’

  • ‘gpu’


input (TensorList) – Input to the operator.

Keyword Arguments
  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • dtype (nvidia.dali.types.DALIDataType, optional, default = DALIDataType.NO_TYPE) –

    Output data type.

    Supported type: FLOAT. If not set, the input type is used.

  • normalized_kernel (bool, optional, default = False) – If set to True, automatically scales partial derivatives kernels. Must be False if scale is specified.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • scale (float or list of float or TensorList of float, optional, default = [1.0]) –

    Factors to manually scale partial derivatives.

    Supports per-frame inputs.

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.

  • smoothing_size (int or list of int or TensorList of int, optional) –

    Size of smoothing window used in convolutions.

    Smoothing size must be odd and between 1 and 23.

    Supports per-frame inputs.

  • window_size (int or list of int or TensorList of int, optional, default = [3]) –

    Size of derivative window used in convolutions.

    Window size must be odd and between 3 and 23.

    Supports per-frame inputs.