singer-yang / DeepLens

DeepLens: a differentiable ray-tracer for computational lens design.
Other
144 stars 22 forks source link

How to calculate the PSF at arbitrary x, y coordinates in meters and Full Sensor PSF calculation support #8

Open David-Morales-Norato opened 2 months ago

David-Morales-Norato commented 2 months ago

Hi,

Thank you for your amazing work and for making this repository available!

I'm interested in applying your model to my current research, but I've encountered two issues that I am unsure how to address:

  1. PSF Coordinates in Meters:
    I'm working with 3_psf_net.py, which calculates the PSFs at coordinates $x \in [-1, 1]$ and $y \in [-1, 1]$ within a normalized range. For my application, however, I need to compute the PSF for a set of real-world coordinates $x \in \mathbb{R}$ (in meters) within the field of view (FOV). Could you provide guidance on how to modify the code to calculate the PSF at these real-world coordinates?

  2. PSF Across the Full Sensor:
    In the current code, the PSF is constrained within a $k \times k$ kernel. For my use case, it would be more useful to specify $x, y$ coordinates on the sensor and compute where the PSF falls on the full sensor array. Initially, I expected that the center parameter in functions like psfnet.lens.psf(...) would define this behavior, assuming the $k \times k$ matrix represents the entire sensor. However, it seems that this isn't the case. Could you clarify how to adapt the code to calculate the PSF at specific coordinates on the sensor plane, rather than within a fixed kernel size?

I appreciate your time and assistance in helping me better understand how to adapt your code to these needs. Thank you again for your excellent contribution to the community.

Best regards,
DSMN

singer-yang commented 2 months ago

Hello David,

Thanks a lot for your interest!

  1. PSF Coordinates in Meters You can use lens perspective to convert world (physical) coordinates to homogenous (normalized) coordinates. The magnification factor can be obtained from function GeoLens.calc_scale_pinhole().

  2. PSF Across the Full Sensor You can obtain the full-sensor PSF by setting the PSF center to (0, 0) and PSF resolution to sensor resolution. Please check https://github.com/singer-yang/DeepLens/blob/main/deeplens/geolens.py#L1287 for a reference.

For further questions, please feel free to ask me :-)

Best, Xinge