This article describes how to use the Image Simulation analysis tool to produce photorealistic images of object scenes including the effects of diffraction, aberrations, distortion, relative illumination, image orientation and polarization.
Authored By: Mark Nicholson
IntroductionZemax supports an Image Simulation feature that quickly and accurately predicts the appearance of any scene as imaged by the optical system. The method works by convolving a source bitmap file with an array of Point Spread Functions. The effects considered include diffraction, aberrations, distortion, relative illumination, image orientation, and polarization. The new feature is very fast, fully multi-threaded to operate over all the CPUs in your computer and gives excellent signal/noise in the final image.
Please open the supplied sample file {Zemax_install_folder}/samples/sequential/Image Simulation/Example 1, a singlet eyepiece.zmx. The Settings dialog box for this feature sets out the controls in a logical manner:

A source file, which can be a .bmp, .jpg, .ima or .bim, is read in and given a full height in whatever the field units of the lens are (although object height is the natural field definition for this feature). The input scene can be rotated, flipped, and resampled as necessary, and is then centered on the specified field point.

A grid of point spread functions are then computed. The grid spans the field size, and describes the aberrations at selected points in the field of view defined by the bitmap and field size settings. The PSF grid also includes the effects of polarization and relative illumination.

In this case the central PSF is very well formed, but as we go out in the field it becomes considerably aberrated, and the coma in the corners is very visible. The PSF grid is interpolated for every pixel in the modified source bitmap. At each pixel, the effective PSF is interpolated between the nearest PSF points in the grid, and is then convolved with the modified source bitmap to determine the aberrated bitmap image. The resulting image bitmap is then scaled and stretched to account for the detected image pixel size, geometric distortion, and lateral color aberrations.

Image Simulation is very fast,
fully multi-threaded to operate over all the CPUs in your computer and gives excellent signal/noise in the final image. As a benchmark, the above Image Simulation completes in about 10 seconds on a 2-CPU Core-2 Duo laptop, and in only 3 seconds on an 8-CPU Dell Precision 690 workstation.
We will go on to consider how best to set up Image Simulation, and how to detect and avoid common errors.
How to Use Image SimulationIn most cases, the defaults Zemax chooses result in usable results with little user intervention. However its always best to really understand what the calculation is doing! Also, if you don't understand or don't agree with the predicted results, you can take full control of each step of the calculation. Here is the process to go through to set up the Image Simulation in a robust manner.

1. Choose your input scene, and then under the PSF Grid Settings choose Aberrations: None and set the PSF x, y points to 1 in each case. This will make the PSF grid a single delta function. Any function convolved with a delta function yields the initial function, hence the resulting simulated image will be exactly the same as the input scene, except it will suffer the distortion of the optical system.
2. Set 'Show As' to Simulated Image, with the detector Pixel Size, X-Pixels and Y-Pixels set to 'default'. You can either type the word default into the settings, or just enter the numerical value 0. Zemax will then set the number of pixels in the detector equal to the number of pixels in the source bitmap, and set the size of the detector pixels equal to the size of the central pixel in the source bitmap as magnified through the optical system. A useful 'baseline' system should result. You can set the detector to be centered on the chief ray, so it automatically moves as the input scene moves around the field of view, or set it to be positioned relative to the surface vertex. Take the time now to set up the detector the way you want it before proceeding on.
3. Once the detector is set up correctly, it is time to set up the PSF grid. Set 'Show As' to PSF Grid, and select Aberrations to be either Geometric or Diffraction. If the RMS Spot Radius is much larger than the Airy disc everywhere in the field of view, use Geometric. If the spot radius is close to (or less than) the Airy radius, select Diffraction. Use the Diffraction setting also if the lens is diffraction limited over some part of the field of view, and not diffraction limited elsewhere: Zemax will automatically switch to use Geometric at those points in the grid where the PSF is more than 20 times the diffraction limit.
Set the PSF x, y points as appropriate. Remember that Zemax interpolates the PSF between the measured points. The number of points in x or y is correct when no significant change occurs when these numbers are changed (just as with any sampling control).
The PSF Grid has the same size and resolution of the source bitmap. If a PSF grid point looks like so:

then the point spread function is small compared to the source bitmap pixel size. If a PSF grid point looks like so:

then the PSF is large compared to the source bitmap pixel size.
If your PSF grod looks lke the first of these examples, then the source bitmap can be oversampled, or the height of the source bitmap reduced, in order to make the PSF grid large compared to the pixel size. Generally, if diffraction effects are important then the source bitmap pixels (after any oversampling, if necessary) should be comparable in size to the PSF. The PSF grid should be several pixels wide if diffraction or aberration effects are important.
4. Once the PSF Grid is satisfactory, set 'Show As' to Simulated Image to see the results of the convolution.
Examples of UseZemax ships with several examples of the usage of this feature which you should investigate prior to using the feature. The supplied examples are located in the {Zemax Install Folder}\Samples\Sequential\Image Simulation folder, and are:
Example 1, A singlet eyepieceThis is a classic example of the use of this feature. This lens is an eyepiece, but note that it is not an afocal system: it is focal with the image formed -1000 mm away (giving 1 diopter of accommodation). The image formed is virtual, but it is a focal system. The aberrations are so large that the relative illumination contribution cannot be computed. In this case, the relative illumination is set to be uniform everywhere.

Note the statement in the text below the Simulated Image. Also note that the PSF grid may look as if some points are missing:

But this is just the result of sub-sampling on the monitor's screen. The input scene is 640 x 480 pixels, so the PSF grid is also. However the PSF grid is being displayed is a smaller window. In this case the whole Analysis window is only 550x 460 pixels, and the PSF grid is within say two-thirds of this: which means the PSF grid is sub-sampled. If the window is maximized, or at least set larget than the 640x480 pixels needed by the PSF grid, the whole grid can be seen:
Example 2, Double Gauss Experimental ArrangementZemax allows four definitions of the field of view: field angles, object height, and real and paraxial image height. All four are valid ways of defining the field of view, but for the purposes of this feature -simulating the image of a bitmap input scene- object height is the preferred field definition.
The double Gauss was originally optimized with the object at infinity, and with angles as the field definition. However, if the bitmap image is used with field in degrees, then each pixel corresponds to some angular range: which is probably not what the experimental or test arrangement is. Worse, angular pixels are inherently anamorphic. An x-width of say 1 degree is a different subtended angle if the y-angle is 80 degrees than if the y-angle is 10 degrees. If field angles are being used, and the field of view is fairly wide (more than about 40 degrees in any direction) then great care should be taken in interpreting the results for an extended object.
This file shows the double-Gauss in its likely test configuration:

Here, an auxilliary collimating lens is used to image the test scene to infinity, and the infinity-focused double-Gauss forms the image of the test scene. In this case a paraxial lens is used to represent the auxilliary collimating lens, but this case be replaced with a real lens design if required. The important issue is that the test pattern has a defined spatial extent, so that each pixel represents the same patch of illuminating area as any other.
Similarly, real image height should not be used as the field definition when evaluating image performance with Image Simulation, or when computing any kind of distortion. When using real image height, Zemax iterates each chief ray trace to find the exact object space angle to hit the desired image coordinate. Because the desired image coordinate is always reached, the image height is linear with field coordinate. The iteration is thus implicitly removing the distortion. Instead, Zemax automatically changes the field type from real image height to paraxial image height for the purposes of Image Simulation, and issues a message to that effect.
However, even paraxial image height is not ideal, as any anamorphic magnification of the lens (if present) will be ignored. Remember that if fields are defined by image height, then the Field Height control determines the size of the object in
image space, not object space. The Field Height is always in whatever units the fields are defined in! Object height is the most natural field definition to use with Image Simulation (or
Geometric Bitmap Image Analysis), as it defines the size of the input source bitmap unambiguously.
Example 3, A blue notch filter
Zemax can also account for the polarization properties of the optical system (EE only) on image formation. In this case a source scene consisting of overlapped red, green and blue circles

is imaged by a lens that contains a blue notch-filter that rejects the blue light. The resulting image is formed without any blue component:
Example 4, a diffraction limited systemIn this example, a low resolution scene is imaged through a diffraction limited system (the Hubble Space Telescope). In order that the input pixels be of the order of the PSF, the input scene is oversampled 16x to produce this PSF grid:

Note that in this design the field of view is in angles, but the angular field of view is so small (0.001°) that the anamorphic issues discussed above are not relevant.
Example 5, spatially varying resolutionThe same double-Gauss experimental arrangement is used as in example 2, but in this case the test pattern consists of grid lines of varying spatial frequencies and orientations. The input scene is shifted around in the field of view by changing the field number, and the detector is always located relative to the chief ray from the viewed reference point. The effect of the different contrast (MTF) in the sagittal and tangential directions can be easily seen, as can lateral color. Again the windows should be maximized or at least be larger than the pixel resolution of the input scene (201 x 201 pixels).
Example 6, tilted image planeIn this case the object and image planes are tilted to induce keystone distortion and focal plane blurring. In configuration 1 there is no tilt, and the PSF grid is diffraction limited over the field of view. In configuration 2 (use control-A to switch configurations) the tilt results in the system being well away from diffraction limited at the top and bottom of the field of view:

with the image being diffraction limited in the central x-scan but out of focus at the top and bottom:

Note that the PSF grid automatically switches to geometric for any field point where the PSF is more than 20x the diffraction limit, so that Image Simulation uses diffraction effects wherever they can be computed, and switches to a geometric calculation as and when needed.
The Other Image Analysis Features Zemax also supports several other Image Analysis features under the Image Simulation menu:

When should they be used?
Geometric Image Analysis (GIA) is limited to geometric (hence no diffraction) computations of relatively low resolution .IMA and .BIM bitmaps. However, it can be calculated on any surface, whereas the convolution-based Image Simulation can only be computed on the Image surface. Also, as GIA is ray-tracing based, it can be used to compute system efficiency and also
multi-mode fiber coupling. The IMAE operand allows the system efficiency to be used as a target in the merit function.
Geometric Bitmap Image Analysis (GBIA) is very similar to Image Simulation in that .bmp or .jpg source bitmaps can be imaged through an optical system. Generally speaking, Image Simulation (IS) will give much higher signal-to-noise ratio images more quickly than GBIA. With GBIA, the signal/noise is proportional to SQRT(n) where n is the number of rays traced per pixel.
Detecting undersampling in the PSF grid of IS is more tricky. Badly-sampled PSF grids almost always look like delta functions, which means that the convolution-based method may predict performance that is better than is achievable in reality if the PSF grid is not set up adequately. GBIA provides a useful double-check on the predicted performance. GBIA can also be computed on any surface, i.e. far from focus.
Partially Coherent Image Analysis (PCI) was formerly known as Diffraction Image Analysis. If the incoherent imaging of a bitmap through a diffraction limited system is needed, IS is generally superior to this method. However PCI allows the
coherence of the source illumination to be included. This is an important effect in photolithography systems in particular.
Extended Diffraction Image Analysis (EDIA) is effectively replaced by the IS feature, if the source scene is incoherent. However, EDIA allows for coherent imaging of extended source scenes, and also allows each pixel in the source bitmap to represent a delta function. This is useful for checking the imaging of extended scenes that consist of point sources like stars.