tidy3d.plugins.autograd.invdes.GaussianFilter

tidy3d.plugins.autograd.invdes.GaussianFilter#

class GaussianFilter[source]#

Bases: AbstractFilter

A Gaussian filter implemented via separable gaussian_filter primitive.

Parameters:
  • kernel_size (Union[PositiveInt, tuple[PositiveInt, ...]]) – Size of the kernel in pixels for each dimension.

  • normalize (bool = True) – Whether to normalize the kernel so that it sums to 1.

  • padding (Literal['constant', 'edge', 'reflect', 'symmetric', 'wrap'] = reflect) – The padding mode to use.

  • sigma_scale (NonNegativeFloat = 0.445) – Scale factor mapping radius in pixels to Gaussian sigma.

  • truncate (NonNegativeFloat = 2.0) – Truncation radius in multiples of sigma passed to gaussian_filter.

Notes

Padding modes 'constant', 'edge', 'reflect', 'symmetric', and 'wrap' are supported. Modes 'edge' and 'symmetric' are internally mapped to the SciPy equivalents 'nearest' and 'mirror' respectively. The default sigma_scale of 0.445 was tuned to match the conic kernel when expressed in pixel radius. The normalize flag inherited from AbstractFilter is ignored because the separable Gaussian implementation always returns a unit-sum kernel; setting it to False has no effect.

Attributes

sigma_scale

truncate

kernel_size

normalize

padding

Methods

get_kernel(size_px, normalize)

Get the kernel for the filter.

sigma_scale#
truncate#
static get_kernel(size_px, normalize)[source]#

Get the kernel for the filter.

Parameters:
  • size_px (Iterable[int]) – Size of the kernel in pixels for each dimension.

  • normalize (bool) – Whether to normalize the kernel so that it sums to 1.

Returns:

The kernel.

Return type:

np.ndarray