nvidia.dali.fn.laplacian¶
-
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. Ifsmoothing_size
is specified, the smoothing windows applied to a given axis can have different size than the derivative window. Specifyingsmoothing_size = 1
implies no smoothing in axes perpendicular to the derivative direction.Both
window_size
andsmoothing_size
can be specified as a single value or per axis. For example, for volumetric input, ifwindow_size=[dz, dy, dx]
andsmoothing_size=[sz, sy, sx]
are specified, the following windows will be used:for partial derivative in
z
direction: derivative windows of sizedz
alongz
axis, and smoothing windows of sizesy
andsx
along y and x respectively.for partial derivative in
y
direction: derivative windows of sizedy
alongy
axis, and smoothing windows of sizesz
andsx
along z and x respectively.for partial derivative in
x
direction: derivative windows of sizedx
alongx
axis, and smoothing windows of sizesz
andsy
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 by2^(-s + n + 2)
, wheres
is the sum of the window sizes used to calculate a given partial derivative (including the smoothing windows) andn
is the number of data dimensions/axes. Alternatively, you can specifyscale
argument to customize scaling factors. Scale can be either a single value orn
values, one for every partial derivative.Operator uses 32-bit floats as an intermediate type.
Note
The channel
C
and frameF
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’
- Parameters
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) –
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.