Posted by: recordingsofnature | September 5, 2014

Simulation of DSLR image sampling to reproduce video aliasing and Moiré artifacts from pixel binning, pixel skipping and demosaic processes

With this investigation I hope to bring a view into how various low-level image sampling and related processes, including pixel binning, pixel skipping and Bayer demosaic algorithms, affect the image quality particularly with respect to the appearance of aliasing and Moiré.

The focus here is DSLR video systems, which typically use quality compromising methods to reduce the computational load when  scaling down of the multi-MP sensors designed for still images. As the pixel count of those sensors increases the down-scaling becomes more demanding and computational heavy.

While newer DSLR cameras seem to have come a long way solving this problem, aliasing is still a main problem for many digital cameras, and it is not an easy tassk to find information on what underlying processes are. Having this information is crucial for the design of optical antialiasing filters (low pass filters)  matching the various  DSLR video cameras.

In this (rather long) article I will present simulation results from a range of different pixel binning, pixel skipping and demosaic schemes (btw. chroma subsampling no included) in order to see the effect on image quality and to see if it is possible to replicate the observed aliasing and Moiré of the Nikon d5100 best. This may also be used to evaluate the sampling method of other cameras, when using the same video test and compare with the simulation results.

Aliasing and Moiré video observations

Let us start up by looking at some raw video footage of the Nikon d5100 when shooting a test line chart highly prone to aliasing and Moiré. All are captured with an 18-55mm kit lens. Typical f=22mm and f/5.6.

Take 1, f=22mm

Take 2, repetition of Take 1 but different lightning conditions. F=28mm

Take 3 , repetition now using antialiasing filter, CYL 75 at f=22mm , 1/f = 6.3

Test chart

The test chart used, is a customized chart designed to give a quick overview of aliasing and Moiré performance for horizontal and vertical lines, as well illustrating the general image quality. A similar test chart is used in this post on Pixel fill factor.

Test chart with indication of locations of the harmonics of the Nyquist frequency

Test chart with indication of locations of the harmonics of the Nyquist frequency

The test chart contains vertical and horizontal line patterns with gradual increasing line densities ranging from 0.5 to 4 times the Nyquist frequency (Nq= Fs/2). This is indicated by arrows in the figure. Note, the Nyquist frequency is seen with respect to the sampling rate of the sampled image. For the video footage, the test chart was printed out (A2 size) from this original high-res image.

Summary of video observations

Typical aliasing and Moiré patterns at the center of the image frame

Typical frame grab of aliasing and Moiré patterns at center location

Typical video frame grab of the test chart at the center location (Take 1). Corresponding full scale still images are here (take1) and here(take2)  (converted from RAW with Ufraw using simple bilinear demosaic). Two line bar RMS amplitude analysis diagrams are added to the charts to provide a quick overview of the frequency response of vertical (left) and horizontal (right) lines. The red, green and blue curves represent the respective color channels. The red vertical line indicates the Nyquist frequency (Nq).

The capture of the figure – and all the following – are taken at a specific zoom level, where the primary Moiré resonances appears to match the Nq x 1 and Nq x 2 according to the indications on the test chart. Knowing the Nyquist frequency gives the sampling rate and thus effective video resolution, which in this case turn out to be 1642 x 923 px. This equals a down-scaling of the full image sensor resolution by a factor 3. In order for the image to reach full HD resolution of 1980 x 1080, the image is apparently scaled up by 16%  during a later process. This is in line with the observations of this earlier blog post on Moiré testing.

Horizontal lines:  Lots of banding and coloring is present, strongest around the harmonics of Nq.  At Nq x 1, lines are blurred and very colorful with pink and green bands. At Nq x 2 the bands are less colorful, now featuring black and white bands with elements of blue and brown.

Vertical lines: Moiré banding is present throughout the frequencies, again strongest around harmonics of Nq, but generally much fainter compared to horizontal lines. Many of the same color combinations and interferences can be identified for both horizontal and vertical lines.

Aliasing and Moiré at the bottom edge position

Typical frame grab capture of Aliasing and Moiré pattern at the edge of the image frame.

Typical frame capture when test chart is moved to the bottom edge of the image frame.The corresponding full resolution raw still image is here.

It is a clear, repeatable observation, that the colors of the Moiré banding enhances radically when the line pattern is moved away from the center and towards the bottom of the image frame.  This is probably related to chromatic aberrations of the lens, or the OPLF when light hits the sensor at oblique angles. This effect explains why the coloring of Moiré differs so much for different types and lengths of lenses.  For still images, this effect is normally compensated by lens models, but these are apparently not used in video mode.

Applying Antialiasing filter(blur filter)

Typical frame grab capture of Aliasing and Moiré pattern at the center of the image frame, with CYL75 aliasing filter

Aliasing filter ,Center position. Typical frame grab with the test chart in the center of the image frame, while applying aliasing filter ( CYL75  f=22mm, 1/f=6.3)


Typical frame grab capture of Aliasing and Moiré pattern at the edge of the image frame, with CYL75 aliasing filter

Aliasing filter, edge position. Typical frame grab capture with the test chart in the bottom edge of the image frame, with aliasing filter  (CYL75 f=22mm, 1/f=6.3)

When an antialiasing filter (blur filter) is applied the banding and coloring are strongly attenuated. The ‘MTF’ curves now show minimal amplitude for frequencies above Nq, both for vertical and horizontal lines. The color bands for Nq x 1 can still be seen, but all other bands are removed.  The optical blur method clearly removes banding and coloring which are very difficult to remove in post processing.

Sampling simulation

To get a better view of how these Moiré artifacts are created, I have attempted to simulate the image sampling process. By integrating different binning, pixel skipping and demosaic processes in the simulation I will see which processes best replicate the observed artifacts.

Sampling model

For the simulations, I am assuming the following sampling model as shown on the figure below. I am aware, that this is a simplified model of actual DSLR cameras, and various steps may be added/omitted for different camera models. Of the 7 steps, the simulations only includes steps 1-5 of the sampling model, hence no image post processing, chroma subsampling or video encoding.


Image sampling model

  1. Optical domain filters and transformations before landing on the sensor. An optical antialiasing filter can be inserted at this point to generate a low pass filtering of the image.
  2. The OPLF, Optical low pass filter, is a built-in filter of the sensor serving to spread the light to cover all four RGGB bayer cells. It consists of a stack of thin birefractive layers on top of the image sensor which splits the light into four beams hitting the four bayer sub pixels. This is parametrized with an x and y displacement distance.
  3. The optical image is then sampled through a Bayer color masks, which has 4  RGGB square pixel apertures. The image is now described in a color filter array (CFA) format.  All the optical filters of step 1-3, – optical blur, OPLF and pixel aperture – are in the simulation represented by a combined sampling filter.
  4. Pixel binning and/or pixel skipping processes taking place at sensor  CMOS level, thus saving computational costs. The binning process combines charges of pixels of the same color by adding the collected charges. This produces a new CFA matrix now with a down scaled resolution. Skipping of pixels or rows of pixels are also included at this step.
  5. The demosaic (debayer) process  converts the CFA data into RGB pixels by applying various smoothing filters. These are arithmetic operations and therefore relatively computational heavy. The output is normally an RGB array with the same resolution as the CFA sub pixels.  In the simulations the bilinear demosaic (BD) method is used as standard.
  6. Image processing and enhancements of sharpness, color, contrast etc.
  7. Video encoding processes, including chroma sub sampling, and rescaling

Pixel binning is an effective method to downscale sensor resolution, while in the same time improve low light and noise performance. Not all DSLR image sensors apply pixel binning. E.g. the present Nikon D5100 used in this work, uses the Sony MX071   image sensor which appears not to use pixel binning. However, that said, detailed data sheets and specifications for this  sensor is not easy to find.  The same sensor is also used in Nikon 7000, Fuji X-Pro1, Pentax K-5, Pentax K-01, Pentax K-30, Sony a580, Sony A55, Sony NEX-5N, Fuji X-Pro1, Sony NEX-5N, Fuji X-Pro 1.  The Aptina mt9h004  is an example of an image sensor which uses 2×2 binning.

Results from the simulations

The sampling model, step 1-5, was implemented in Scilab. A high resolution test image (same as for the video test)was used as input representing the incident optical image. This image has 4×4 pixels for each sampled pixel (Bayer sub-pixel).

The Moiré coloring appears to be very sensitive to chromatic aberration effects. In the simulations, this has been modelled by a simple prismatic color displacement (phase shift) during the CFA sampling which corresponds to the results termed ‘Chr. abr’.

Since the focus is on aliasing effects for horizontal lines, I am in the following focusing on pixel schemes which in different ways combines or skips rows of pixels, ie. only skipping in the vertical direction.

In the case of the Nikon d5100 the original sensor resolution of 16MP has to be down scaled to 1/3, which means each final RGB pixel covers an area of 3×3 CFA subpixels. Of course other schemes may apply for other camera models.  But in this case only the 3×3 schemes will result in the correct final resolution.  The 2 x 2 schemes will produce an image with too high resolution, unless an additional post down scaling of the image is applied.

2×2 pixel binning

Starting with 2×2 binning schemes, which down scales the resolution as indicated on the diagrams. The binning is here – and for all  the following binning simulations – followed by a standard Bilinear demosaic process. Results named’ Chr. abr.’ has added chomatic aberration.

In the following binning diagrams all pixels with the same number on the left side are combined into the pixel of the same number on the right hand side.

2.0Binning 2.0 + BD: StandardChr. abr.  (6 px)

Pixel binning 2.1Binning 2.1 + BD:  StandardChr. abr. (6px)

2 x 2 binning produces relatively good image quality as long as no pixels are skipped.

The Binning 2×2 binning schemes downscales the resolution by 2 x 2, and will produce too large images compared to the Nikon d5100 (which need 3 x 3 down scaling). However this binning scheme may be relevant for other cameras.

2.0Binning 2.0 + BD  followed by a 33% linear downs scaling:  Standard (4px)

This produces the correct sampling resolution could be realistic. But the characteristics on the banding lines is very different from the observed patterns of the video footage. The 2×2 binning process is not likely involved in the present sampling mehods.

3×3 pixel binning

The 3.x binning processes combined with a standard bilinear debayer process produces the correct resolution, and may readily be applied in a sensor to save image computations. The 3.0 utilizes all sensor pixels., while 3.0x skips lines.

3.0Binning 3.0 +  BD : Standard, Chr. abr.

3.01Binning 3.01 + BD : StandardChr. abr.

3.02Binning 3.02 + BD : StandardChr. abr.

3.03Binning 3.03 + BD :  StandardChr. abr.

The pixel binning schemes 3.0-3.03 which combines line skipping produces strong colorful Moiré patterns. However, these patterns produced from are some how different from the patterns from the video tests. There are certain specific differences, especially for Nq x 1 and Nq x 2.

Lets try some other combinations:

3.3Binning 3.3 + BD:  StandardChr. abr.

Binning scheme 3.3 skips 2 out of 3 lines and produces Moiré patterns which actually has many similarities to the video observations, however the resolution appears lower.

3.13Binning 3.13 + BD :  StandardChr. abr.

3.11Binning 3.11 + BD :  StandardChr. abr.

3.2Binning 3.2 + BD: Standard, Chr. abr.

Binning schemes 3.13-2.3 also show a good similarity with the video observations. The schemes appear to produce variations over the same theme. Scheme 3.11 has the closest match. Again the overall resolution of these results appear to be lower than the observations of the video.

Special demosaic schemes

Another approach of processing for downscaling the  CFA data to RGB  is using a dedicated demosaic algorithms, without binning.  This approach could be more computational heavy since a higher number of pixels (up to 66 to 100% of all) must be processed through  arithmetic operations. On the other hand, no subsequent demosaic process is needed.   Below are a set of specialised demosaic schemes and results of the simulations.

Full Special full debayer : Standard, Chr.abr.

B1 Special b1 debayer:  Standard, (+ smoothing)  Chr. abr.  (+ smoothing)

B1.1 Special b1.1 debayer: Standard,   Chr. abr.

This method produces more details, and seems to be of higher resolution. Special debayer scheme B1 gives very comparable results to the video tests, especially when the result is slightly smoothed. B1 is sampling the same sensor pixels as binning 3.11, and the results seems to be in the same family.


No perfect match is found, however the simulations are able to reproduce the observed interefence and Moiré featues quite accurately and with almost the same coloring.The best candidates variation of sampling filter are binning type 3.11, 3.3 and demosaic B1, whereof B1 overall is the best match. After a bit of fine tuning with post blur filters the charts below gives an overview of the different methods compared to the original video screen capture.

Normal colors:

Best candidates, center colorsEnhanced colors at the bottom edge (Chr. abr.):

best candiates - Edge colorsWith the simulations it was possible to make a good reproduction of the observed Moiré  features. The contrast and colors are generally stronger on the simulation results. Most of the Moiré interferences follow exactly the same patterns. The demosaic method B1 seems to be of higher resolution compared to the binning 3.3 and 3.11. 3.3 has very saturated colors. Since no color processing is made in the simulation results, the colors may be sligthly misguiding.

Simulating the CYL aliasing filter

Here in the end, I will present a quick investigation of the effect of using a simple optical blur filter as anti aliasing filter. Such filter is here modeled in the simulations by adding a blur disk with a given diameter (added to the sampling filter). When gradually incrasing the diameter of the blur disk  from 6 to 24 pixels (corresponding to 0.75 – 3.0 pixels video resolution) on the pixel binning 3.3 scheme and B1 demosaic scheme the results are:

Using the enhanced edge color versions (Chr. Abr.)

06result_binning62580   00result_binning34413 Binning 3.3 and B1 – No aliasing filter

06result_binning6258006result_binning86957Binning 3.3 and B1- 0.75 px blur

12result_binning5251312result_binning11183Binning 3.3 and B1- 1.5 px blur

16result_binning317716result_binning13948Binning 3.3 and B1- 2.0 px blur

20result_binning9355320result_binning2554Binning 3.3 and B1- 2.5 px blur

24result_binning1922224result_binning44589Binning 3.3 and B1 – 3 px blur

The aliasing artifacts and coloring are effectively attenuated when applying a blur circle of 2-3 pixel (video resolution) diameters, for both sampling schemes, 3.3 binning and demosaic B1. In the same time, it is hardly noticeable that the detail or sharpness of the image is degraded.  However, the image gets noticeable smoother. The results are comparable with the video observations.

Based on the simulation, there is a  good indication that an antialiasing filter with 2-3 video pixel wide blur circle, with respect to the used sampling resolution, would work for the Nikon d5100. When designing antialiasing filters for other cameras, it is important to know the actual sampling resolution (ie seen from the Nyquist resonances etc.) and to know the level of pixel binning / pixel skipping that is used. By using the test chart presented in this article, and with comparizons with the simulation results, I believe it should be possible to determine the critical factors for other cameras and thereby estimate the optimal antialiasing filter designs.



  1. This was an extremely interesting experiment even thought a lot of it was way above my, let’s say “knowledge level.” For my own purposes, it seems like I’m constantly running into situations where I want to recreate the effect of certain patterns/”moire” (I’m probably being too inclusive with how I use that term, but as I said, I’m still at a beginner’s level when it comes to the actual science of video/DSLR images). Or, much more frequently, trying to prevent the appearance of these while recording video since filters generally can only do so much in post. Going to try to learn more and come back to this post and hopefully understand what I’m looking at a bit more fully. 🙂


  2. Hi Phil

    I have bought your CYL filters before (with which I have been quite happy so far) and see that you really take this matter serious! Do you still sell the anti-moire filters? Maybe you should open a real production as Mosaic guys do?

    Best regards


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: