Authored by Sean Lin, Wilson Chen
Purple fringing is a common and visually noticeable artifact in digital images. However, it is not fully explained by classical definitions of chromatic aberration, such as lateral and longitudinal types. These classical models rely on the behavior of a limited set of rays—typically the chief or marginal rays—which do not accurately represent the full distribution of light within an optical system.
Ansys Zemax OpticStdio has an Image Simulation (IS) analysis tool that can simulation images with colored output based on the point spread function (PSF). Since what each RGB channel represents is complex, the IS tool only simulate each RGB channel using a single wavelength. However, in the real world, each RGB channel has its own spectral response. To accurately simulate purple fringing, it’s important to consider the RGB response behavior of the sensor.
This article demonstrates how to simulate the purple fringing using the RGB response curve of the sensor through the ZOS-API through Python. The first step is to read each RGB response curve in CSV format and build the corresponding spectrum for each configuration. The second step involves running the PSF simulation for each configuration, combining the RGB PSFs, and convolving the resulting colored PSF with the EDGE pattern to simulate purple fringing at the assigned field. The EDGE pattern is used because purple fringing typically appears at high-contrast boundaries, such as the transition between bright and dark regions in an image.
The first step is to build the RGB spectral response for each configuration from a CSV file. The data format of the CSV file is as shown in Fig. 1: the first row contains the column headers, and the remaining rows contain the response data in the format [wavelength, R response, G response, B response]. Save the CSV file in the same directory as the script ‘step1. RGBresponse2Config.py’. Then click the Interactive Extension in Programing Tab (as shown in Fig. 2) and run the ‘step1. RGBresponse2Config.py’ to generate the RGB spectral response for each configuration. Then this step will generate and save a separate file named ‘XXXXX_RGB_Config.zmx’ in the same directory, which will be used in the next step.
Fig 1. The CSV format of the RGB response data
Fig. 2 Interactive Extension in Programing Tab
The second step runs the PSF simulation for each RGB channel (via separate configuration). Each PSF result is then combined into a colored PSF, and applying convolution the colored PSF with the EDGE pattern to simulate purple fringing. This demonstration provides two types of colored PSF: (1) FFT PSF and (2) Huygens PSF using the script ‘step2. main_fft.py’ and ‘step2. main_huygens.py’, respectively. Before running the step2 scripts, you can set the simulation field using the variable ‘fieldN’. The PSF simulation parameters can be set in the region shown in Fig. 3. Then, just like in step1, click the Interactive Extension in Programing Tab and run ‘step2. main_fft.py’ or ‘step2. main_huygens.py’. The python script will produce the individual RGB PSFs, the combined colored PSF, and simulated purple fringing based on the EDGE pattern, as shown in Fig. 4.
By utilizing the ZOS-API, python can generate the RGB response for each configuration. The ZOS-API is then used to call the Ansys Zemax OpticStudio for the PSF simulation, and the results are integrated through python to produce realistic purple fringing effects based on the sensor’s RGB response.
(a)
(b)
Fig. 3 The script‘step2. main_fft.py’ and ‘step2. main_huygens.py’
(a)
(b)
Fig. 4 Results of purple fringing simulation
a base on FFT PSF b base on Huygens PSF
Comments
Article is closed for comments.