Modeling Moiré Fringing Effects in OpticStudio Non-Sequential Mode

This article outlines the basic theory of Moiré patterns, and how fringing effects can arise in OpticStudio non-sequential models. The fringing effects of a pattern on a pixelated detector are demonstrated with a basic system in which a patterned slide is projected directly onto a detector, and a more complex system in which the slide is imaged through a lens. Sample files are provided.

Interfering A Patterned Image with a Pixilated Detector
Modeling Moiré Patterning in an Imaging System
Final Remarks
Zachary Derocher
Non-sequential mode


Moiré patterns result when patterns of similar frequency are overlaid. They can be observed in a wide range of systems, and are common everyday life. Taking a picture of your computer screen, for example, will likely reveal this phenomenon. The wavy, relatively low-frequency pattern of dark or colored lines arises because the screen’s pixel grid overlays that of the camera’s detector. Because the pixel densities, sizes, and pitches of the screen and sensor aren’t equal, the screen’s pixels are binned preferentially by some patterned set of detector pixels, resulting in a Moiré pattern.
Consider a simple case: two bar patterns, whose frequencies are slightly different, shown below. The short bars have thickness 1.25 times that of the tall bars. When the patterns are in phase, there is significant white space between the bars. When the patterns fall out of phase, the short grey bars completely fill the white space between tall bars. This resulting low frequency sinusoidal pattern of grey and white is a Moiré pattern. 

In most optical design applications, the effects of Moiré patterns are undesirable. Photographers, for example, go to great lengths to avoid these effects. The reduced pixel pitch and anti-aliasing features of modern cameras help prevent the effect.
This article will discuss how this effect can be modeled in OpticStudio. First, a basic example of a Moiré pattern is demonstrated in Non-Sequential mode. Then, steps are outlined to expand that example to more accurately represent an optical system; an imaging lens system is modeled, and through it the effects of Moiré patterns are demonstrated. 

Interfering A Patterned Image with a Pixilated Detector
OpticStudio’s Non-Sequential mode can be used to model Moiré patterns which arise due to pixilation in digital imaging systems. The most basic system for demonstrating this is a collimated light source shone through a patterned slide, and onto a detector. The interference between the detector’s pixel grid and the slide’s pattern generate Moiré fringes. This example uses a pattern of thin black and white lines. This is analogous to a newscaster wearing a thinly striped shirt. The high frequency pattern on the shirt can give rise to a Moiré pattern when overlaid on the camera sensor, because the pixels and shirt pattern fall in and out of phase.
A file with this system is attached (Moiré_detector_only.zar). With this setup, we can run a raytrace and view a Moiré pattern in the detector viewer. Shown below are the bitmap image Grid_Of_Bars (left), and the Moiré pattern (right).

Notice that although the Moiré pattern matches that of the bitmap, the frequency is significantly lower than the original image’s. The slide’s pattern has 50 cycles per quadrant, or 100 cycles across the full width. The detector has 125x125 pixels in this example. So, for a 40mmx40mm image, the slide’s pattern frequency is 100/40, or 2.5 cycles/mm, and the detector’s pattern frequency is 125/40, or 3.125 cycles/mm. Because these frequencies are close (within 2x), a Moiré pattern is observed. In this case, the frequency of the Moiré pattern is about 21 /40 or .525 cycles/mm. Introducing a tilt to the slide or detector also has interesting effects on the resulting pattern.

Modeling Moiré Patterning in an Imaging System
Next, the previous basic setup is expanded to model an imaging lens system. In particular, an example lens system is imported from sequential mode, and light is made to scatter through the slide object. This is a more realistic system as it simulates point to point imaging, since light is scattered from the object and propogated through a lens system. This process could be used to model Moiré fringing effects in an optical system during the design process.
First, a sample file lens (\Samples\Sequential\Image Simulation\Double Gauss Experimental.zmx) is converted to Non-Sequential mode. This is done through the “convert to NSC” feature in OpticStudio. Then, some cleanup is done in the Non-Sequential Component Editor, and the slide is added. The slide (grid_of_bars.bmp) is inserted between the source and the lens elements, and a lambertian scatter model is applied so that incident light is scattered as it passes through the slide. Lastly, an importance sampling target is set at the image plane, in order to effectively increase the number of rays which reach the image. (For information on Importance Sampling, refer to the knowledgebase article

After these changes are made, the Non-Sequential Component Editor looks like this (note that some columns are hidden in this image):

The file used is available as an attachment to this article (Moiré_Non_Sequential.zar). Finally, a ray trace is run with this setup. Ray Scattering is enabled in the Ray Trace options, and a detector viewer is opened:

As can be seen, a Moiré pattern appears on the image plane. With the slide pattern frequency of 100 cycles per 50mm and a detector with 130 pixels per 50mm, the low frequency Moiré pattern has about 23 cycles per 50mm.
Other Moiré patterns can also be generated by inserting different slides. Below, the sample slide Spoke_1024x953.jpg is used with the same system:

Because the cycle frequency of the slide’s pattern varies with radius, so too does the relative frequency difference between the slide and detector pixels, and thus the Moiré pattern.
One note should be made about this system, about the use of an idealized paraxial lens. This lens is used for this example as a convenience. A “real” model of this system would have a primary optical system in the place of the paraxial lens with the purpose of taking diverging light from the various points across the slide and collimating those rays.  Alternatively, one could place the slide object very far from the lens system, so that the scattered rays incident on the lens system are approximately collimated. Modeling such a system would require a very large number of rays due to the small solid angle subtended by the distant lens system, so a paraxial lens is used to model the ray collimation.

Final Remarks
In sum, Moiré patterns can have an important impact on optical systems, and can be modeled in OpticStudio in Non-Sequential mode. Other bitmaps or array objects could be used as contributors for Moiré patterns. Furthermore, this example could be expanded or altered to model specific detector pixel size and pitch, and for any lens system that can be generated in OpticStudio. Lastly, these techniques could be expanded upon using array objects and color filters to simulate patterning effects due to color filters on image sensors.