Skip to content

Image Simulation API Reference

The src.imgsim module provides functions for simulating images through optical systems via PSF convolution and Monte Carlo ray tracing.


PSF Convolution

Convolve images with point spread functions to simulate lens aberrations.

conv_psf(img, psf)

Convolve an image with a spatially-invariant PSF.

from src.imgsim import conv_psf

rendered = conv_psf(img, psf)  # img: (B, C, H, W), psf: (C, kH, kW)

conv_psf_map(img, psf_map)

Convolve an image with a spatially-varying PSF map. Each field position uses its own PSF kernel.

from src.imgsim import conv_psf_map

rendered = conv_psf_map(img, psf_map)

conv_psf_depth_interp(img, psf_near, psf_far, depth_map)

Depth-dependent PSF convolution with interpolation between near and far PSFs.

conv_psf_map_depth_interp(img, psf_map_near, psf_map_far, depth_map)

Spatially-varying + depth-dependent PSF convolution.

conv_psf_occlusion(img, psf, depth_map)

PSF convolution with depth-based occlusion handling.

conv_psf_pixel(img, psf_map)

Per-pixel PSF convolution (high accuracy, slow).

conv_psf_pixel_high_res(img, psf_map)

High-resolution per-pixel PSF convolution.


PSF Map Utilities

crop_psf_map(psf_map, ks)

Crop a PSF map to a target kernel size.

interp_psf_map(psf_map, grid_size)

Interpolate a PSF map to a different grid resolution.

read_psf_map(filename)

Load a pre-computed PSF map from file.

rotate_psf(psf, angle)

Rotate a PSF by a given angle (for field-dependent rotation).

solve_psf(img_degraded, img_clean)

Deconvolve to estimate the PSF from a degraded/clean image pair.

solve_psf_map(img_degraded, img_clean, grid_size)

Estimate a spatially-varying PSF map from image pairs.


Monte Carlo Rendering

Ray-tracing-based image simulation using Monte Carlo sampling.

forward_integral(lens, img, depth, spp)

Forward Monte Carlo rendering: trace rays from object through lens to sensor.

backward_integral(lens, sensor_points, depth)

Backward Monte Carlo rendering: trace rays from sensor back through lens to object.

assign_points_to_pixels(points, sensor_size, sensor_res)

Bin ray intersection points into sensor pixels for Monte Carlo image formation.


Rendering via GeoLens

The GeoLens.render() method provides a high-level interface to image simulation:

lens = GeoLens(filename="lens_zoo/cellphone.json")

# PSF map convolution (default)
rendered = lens.render(img, depth=10000.0, method="psf_map")

# PSF patch convolution
rendered = lens.render(img, depth=10000.0, method="psf_patch")

# Monte Carlo ray tracing
rendered = lens.render(img, depth=10000.0, method="ray_tracing")