GaussianApodization#
- class deeptrack.aberrations.GaussianApodization(sigma: float | Callable[[...], float] = 1, offset: tuple[int, int] | Callable[[...], tuple[int, int]] = (0, 0), **kwargs: dict[str, Any])#
Bases:
AberrationIntroduces pupil apodization.
This class modifies the amplitude of the pupil function to decrease progressively at higher spatial frequencies, following a Gaussian distribution. The apodization helps simulate the effects of optical attenuation at the edges of the pupil.
Parameters#
- sigma: float, optional
The standard deviation of the Gaussian apodization. Defines how quickly the amplitude decreases towards the pupil edges. A smaller value leads to a more rapid decay. The default is 1.
- offset: tuple of float, optional
Specifies the (x, y) offset of the Gaussian center relative to the pupil’s geometric center. The default is (0, 0).
Methods#
- get(pupil: np.ndarray, offset: tuple[float, float], sigma: float, rho: np.ndarray, **kwargs: dict[str, Any]) -> np.ndarray
Applies Gaussian apodization to the input pupil function.
Examples#
Apply Gaussian apodization to a simulated fluorescence image:
>>> import deeptrack as dt
>>> particle = dt.PointParticle(z = 2 * dt.units.micrometer) >>> aberrated_optics = dt.Fluorescence( >>> pupil = dt.GaussianApodization(sigma=0.5), >>> ) >>> aberrated_particle = aberrated_optics(particle) >>> aberrated_particle.plot(cmap="gray")
Methods Summary
get(pupil, offset, sigma, rho, **kwargs)Applies Gaussian apodization to the input pupil function.
Methods Documentation
- get(pupil: ndarray, offset: tuple[float, float], sigma: float, rho: ndarray, **kwargs: dict[str, Any]) ndarray#
Applies Gaussian apodization to the input pupil function.
This method attenuates the amplitude of the pupil function based on a Gaussian distribution, where the amplitude decreases as the distance from the Gaussian center increases.
Parameters#
- pupil: np.ndarray
A 2D array representing the input pupil function.
- offset: tuple of float
Specifies the (x, y) offset of the Gaussian center relative to the pupil’s center.
- sigma: float
The standard deviation of the Gaussian apodization.
- rho: np.ndarray
A 2D array of radial coordinates normalized to the pupil aperture.
- **kwargs: dict, optional
Additional parameters for compatibility with other features or inherited methods. These are typically passed by the parent class and may include: - z (float): The depth or axial position of the image,
used in certain contexts.
Returns#
- np.ndarray
The modified pupil function after applying Gaussian apodization.
Examples#
>>> import deeptrack as dt >>> import numpy as np >>> import matplotlib.pyplot as plt
>>> pupil = np.ones((128, 128)) >>> rho = np.linspace(0, 1, 128).reshape(-1, 1) @ np.ones((1, 128)) >>> x = np.linspace(-1, 1, 128) >>> y = np.linspace(-1, 1, 128) >>> X, Y = np.meshgrid(x, y) >>> rho = np.sqrt(X**2 + Y**2) >>> pupil[rho > 1] = 0 >>> apodizer = dt.GaussianApodization(sigma=0.5, offset=(25, -3)) >>> modified_pupil = apodizer.get( >>> pupil, >>> offset=(5, -3), >>> sigma=0.5, >>> rho=rho >>> ) >>> fig, axes = plt.subplots(1, 2, figsize=(12, 6)) >>> axes[0].imshow(np.abs(modified_pupil), cmap="gray") >>> axes[0].set_title("Modified Pupil Magnitude") >>> axes[1].imshow(np.angle(modified_pupil), cmap="hsv") >>> axes[1].set_title("Modified Pupil Phase") >>> plt.show() >>> modified_pupil.shape (128, 128)