cambrian.eyes.optics

This is an optics-enabled eye, which implements a height map and a PSF on top of the existing eye.

Classes

MjCambrianApertureConfig

Base dataclass which provides additional methods for working with configs.

MjCambrianCircularApertureConfig

This defines the config for the circular aperture. This extends the base aperture

MjCambrianMaskApertureConfig

This defines the config for the custom aperture. This extends the base aperture

MjCambrianOpticsEyeConfig

This defines the config for the optics module. This extends the base eye config

MjCambrianOpticsEye

This class applies the depth invariant PSF to the image.

Module Contents

class MjCambrianApertureConfig[source]

Bases: hydra_config.HydraContainerConfig, abc.ABC

Base dataclass which provides additional methods for working with configs.

abstract calculate_aperture_mask(X1_Y1, Lx, Ly)[source]

This method calculates the aperture mask.

Parameters:
  • X1_Y1 (torch.Tensor) – Squared distance from the center of the aperture.

  • Lx (float) – Width of the aperture.

  • Ly (float) – Height of the aperture.

Returns:

torch.Tensor – Aperture mask.

class MjCambrianCircularApertureConfig[source]

Bases: MjCambrianApertureConfig

This defines the config for the circular aperture. This extends the base aperture config and adds additional parameters for the circular aperture.

Variables:

radius (float) – Radius of the circular aperture.

calculate_aperture_mask(X1_Y1, Lx, Ly)[source]

This method calculates the aperture mask.

Parameters:
  • X1_Y1 (torch.Tensor) – Squared distance from the center of the aperture.

  • Lx (float) – Width of the aperture.

  • Ly (float) – Height of the aperture.

Returns:

torch.Tensor – Aperture mask.

class MjCambrianMaskApertureConfig[source]

Bases: MjCambrianApertureConfig

This defines the config for the custom aperture. This extends the base aperture config and adds additional parameters for the custom aperture.

Variables:
  • mask (Optional[List[List[int]]]) – Aperture mask. This is a 2D array that defines the aperture mask. The aperture mask is a binary mask that defines the aperture of the lens. It’s a binary mask where 1 lets light through and 0 blocks it. The mask can only be None if randomize is True or if size is not None. Defaults to None.

  • randomize (bool) – Randomize the aperture mask. If True, the aperture mask is randomized.

  • random_prob (Optional[float]) – Probability of the aperture mask being 1. If None, the probability is 0.5. Defaults to None.

  • size (Optional[Tuple[int, int]]) – Size of the aperture mask. If None, the size is the same as the pupil resolution. Defaults to None.

calculate_aperture_mask(X1_Y1, *_)[source]

This method calculates the aperture mask.

Parameters:
  • X1_Y1 (torch.Tensor) – Squared distance from the center of the aperture.

  • Lx (float) – Width of the aperture.

  • Ly (float) – Height of the aperture.

Returns:

torch.Tensor – Aperture mask.

class MjCambrianOpticsEyeConfig[source]

Bases: cambrian.eyes.eye.MjCambrianEyeConfig

This defines the config for the optics module. This extends the base eye config and adds additional parameters for the optics module.

Variables:
  • pupil_resolution (Tuple[int, int]) – Resolution of the pupil plane. This is used to calculate the PSF.

  • noise_std (float) – Standard deviation of the Gaussian noise to be added to the image. If 0.0, no noise is added.

  • wavelengths (Tuple[float, float, float]) – Wavelengths of the RGB channels.

  • f_stop (float) – F-stop of the lens. This is used to calculate the PSF.

  • refractive_index (float) – Refractive index of the lens material.

  • height_map (List[float]) – Height map of the lens. This is used to calculate the phase shift of the light passing through the lens. Uses a radially symmetric approximation.

  • scale_intensity (bool) – Whether to scale the intensity of the PSF by the overall throughput of the aperture.

  • aperture (MjCambrianApertureConfig) – Aperture config. This defines the aperture of the lens. The aperture can be circular or custom.

  • depths (List[float]) – Depths at which the PSF is calculated. If empty, the psf is calculated for each render call; otherwise, the PSFs are precomputed.

class MjCambrianOpticsEye(config, name)[source]

Bases: cambrian.eyes.eye.MjCambrianEye

This class applies the depth invariant PSF to the image.

Parameters:

config (MjCambrianOpticsConfig) – Config for the optics module.

initialize()[source]

This will initialize the parameters used during the PSF calculation.

step(obs=None)[source]

Overwrites the default render method to apply the depth invariant PSF to the image.