mr2.utils.filters.gabor_filters_2d
- mr2.utils.filters.gabor_filters_2d(n_filters: int, kernel_size: tuple[int, int], sigma: float = 2.0, frequency: float = 0.25) Tensor[source]
Create oriented cosine filters under an isotropic Gaussian envelope.
On the pixel grid centered at
((ky - 1) / 2, (kx - 1) / 2), filter \(i\) samples\[g_i(x,y) = \exp\!\left(-\frac{x^2+y^2}{2\sigma^2}\right) \cos\!\left(2\pi f(x\cos\theta_i+y\sin\theta_i)\right), \qquad \theta_i = \frac{i\pi}{n_\mathrm{filters}}.\]The orientations cover \([0,\pi)\) and specify the direction in which the cosine varies. Each sampled filter has its mean subtracted and is divided by its L2 norm when nonzero.
- Parameters:
n_filters (
int) – Number of Gabor filters to generate.kernel_size (
tuple[int,int]) – Spatial shape(ky, kx)in pixels.sigma (
float, default:2.0) – Positive finite standard deviation of the Gaussian envelope, in pixels.frequency (
float, default:0.25) – Spatial frequency of the sinusoidal carrier, in cycles per pixel.
- Returns:
Real Gabor filter bank of shape
(n_filters, ky, kx), using the default floating dtype. Filters have zero mean; nonzero filters have unit L2 norm.