gradoptics.optics.sensor
- class gradoptics.optics.sensor.Sensor(resolution=(9600, 9600), pixel_size=(3.76e-06, 3.76e-06), position=(- 0.0575, 0, 0), poisson_noise_mean=2, quantum_efficiency=0.8, viewing_direction=[1.0, 0.0, 0.0], up=[0.0, 0.0, 1.0], psfs={}, psf_ratio=1)
Bases:
gradoptics.optics.base_optics.BaseOptics
Models a sensor.
- __init__(resolution=(9600, 9600), pixel_size=(3.76e-06, 3.76e-06), position=(- 0.0575, 0, 0), poisson_noise_mean=2, quantum_efficiency=0.8, viewing_direction=[1.0, 0.0, 0.0], up=[0.0, 0.0, 1.0], psfs={}, psf_ratio=1)
- Parameters
resolution – Image processing convention: origin in the upper left corner, horizontal x axis and vertical y axis (
tuple
)pixel_size – Image processing convention: origin in the upper left corner, horizontal x axis and vertical y axis (
tuple
)position – Position of the lens (
list
)poisson_noise_mean – Mean readout noise (
float
)quantum_efficiency – Quantum efficiency (
float
)viewing_direction – Viewing direction of the sensor (
list
)up – A vector that orients the sensor with respect to the viewing direction (
list
) For example, if up=[0., 0., 1.] the top of the camera will point upwards. If up=[0., 0., -1.], the top of the camera will point downwards.psfs – Depth and position-dependant point spread function (
dict
)psf_ratio – Ratio between the psf resolution and the sensor resolution (
int
)
- get_ray_intersection(incident_rays)
Computes the times t at which the incident rays will intersect the object.
- Parameters
incident_rays – The incident rays (
Rays
)- Returns
Times t (
torch.tensor
)
- intersect(incident_rays, t, do_pixelize=True, quantum_efficiency=True)
Returns the rays reflected or refracted by the optical element.
- Parameters
incident_rays – The incident rays (
Rays
)t – The times at which the incident rays will intersect the optical element (
torch.tensor
)
- Returns
(
tuple
) - Reflected or refracted rays (Rays
) - A boolean mask that indicates which incident rays were reflected or refracted ― some rays may not bereflected or refracted for example, due to total internal reflection, which is not modelled at this point (
torch.tensor
)
- pixelize(depth_id, hit_positions, luminosities, quantum_efficiency=True)
Accumulates photons at the pixels hit by some rays at the positions
hit_positions
- Parameters
depth_id – index of the depth (encoded in the PSF) from where the rays come from (
int
)hit_positions – The positions at which the rays hit the sensor (
torch.tensor
)luminosities – The luminosities of the rays (
torch.tensor
)quantum_efficiency – Whether to use quantum efficiency or no (
bool
)
- readout(add_poisson_noise=True, destructive_readout=True)
Readouts the sensor
- Parameters
add_poisson_noise – Whether to add poisson noise or no (
bool
)destructive_readout – Whether the accumulated photons should be destroyed or no (
bool
)
- Returns
The produced image (
torch.tensor
)
- plot(ax, s=0.1, color='grey', resolution_=100)
Plots the optical element on the provided axes.
- Parameters
ax – 3d axes (
mpl_toolkits.mplot3d.axes3d.Axes3D
)
- sample_points_on_sensor(nb_points, device='cpu')
Sample points uniformly on the sensor
- Parameters
nb_points – Number of points to sample (
int
)device – The desired device of returned tensor (
str
). Default is'cpu'
- Returns
Sampled points (
torch.tensor
)
- sample_on_pixels(samples_per_pixel, idx, idy, device='cpu')
Sample data on the pixels whose id are provided
- Parameters
samples_per_pixel – Number of samples per pixel (
int
)idx – Pixel indices along the horizontal axis, assuming a coordinate system centered in the center of the image(
torch.tensor
)idy – Pixel indices along the vertical axis, assuming a coordinate system centered in the center of the image(
torch.tensor
)device – The desired device of returned tensor (
str
). Default is'cpu'
- Returns
(
tuple
) Sampled points (torch.tensor
) and p(A) (float
)