ngclearn.utils.filters package

Submodules

ngclearn.utils.filters.cortical_gauss_filter module

Support for a function/pure “cortical” Gaussian filter - this can be configured to facilitate a filter that engages in a difference-of-Gaussians-like or ratio-of-Gaussians-like process

ngclearn.utils.filters.cortical_gauss_filter.cortical_gaussian_filter(images: Array, sigma_center: float, sigma_surround: float, kernel_size: int, use_ratio: bool = False, semi_sat_constant: float = 0.1, excitation_exp: float = 2.0, inhibition_exp: float = 2.0, edge_pad_mode: str = 'edge') Array[source]

Applies a configurable rectified Gaussian filter (either difference-of-Gaussians, i.e., DoG, or ratio-of-Gaussians, i.e., RoG) to a tensor batch of 2D images (each of CxHxW tensor shape/format). Note that this variant filter means that DoG mode acts more as a (half-wave) rectified subtraction of two Gaussian kernels and RoG mode acts more as simple form of divisive normalization.

Parameters:
  • images – input image tensor of shape (B, C, H, W)

  • sigma_center – standard deviation for narrow / center blur

  • sigma_surround – standard deviation for wide / surround blur

  • kernel_size – kernel radius (window size will be 2*radius + 1)

  • use_ratio – if True, this filter applies a ratio-of-Gaussians (RoG) filter (Default: False)

  • semi_sat_constant – suppresses amplified micro-variations in sensory/image space

  • excitation_exp – p-exponent (typically in range of 1.5 - 2.0) (Default: 2.0)

  • inhibition_exp – q-exponent (typically in range of 1.5 - 2.0) (Default: 2.0)

  • edge_pad_mode – type of image edge-clamping/padding to use, either “edge” or “reflect” (Default: “edge”)

Returns:

An output tensor of shape (B, C, H, W)

ngclearn.utils.filters.gauss_filter module

Support for a function/pure Gaussian filter - this can be configured to facilicate difference-of-Gaussians (DoG) or ratio-of-Gaussians (RoG).

ngclearn.utils.filters.gauss_filter.gaussian_filter(images: Array, sigma_center: float, sigma_surround: float, kernel_size: int, use_ratio: bool = False, edge_pad_mode: str = 'edge') Array[source]

Applies a configurable Gaussian filter (either difference-of-Gaussians or ratio-of-Gaussians) to a tensor batch of 2D images (of CxHxW tensor shape).

Parameters:
  • images – input image tensor of shape (B, C, H, W)

  • sigma_center – standard deviation for narrow / center blur

  • sigma_surround – standard deviation for wide / surround blur

  • kernel_size – kernel radius (window size will be 2*radius + 1)

  • use_ratio – if True, this filter applies a ratio-of-Gaussians (RoG) filter (Default: False)

  • edge_pad_mode – type of image edge-clamping/padding to use, either “edge” or “reflect” (Default: “edge”)

Returns:

An output tensor of shape (B, C, H, W)

Module contents