Thursday 24 October 2013

Simulating microlenses, first take.

Up to now, mtf_generate_rectangle assumed that the simulated sensor had square pixels with a 100% fill factor. This assumption does not reflect reality all that well, but it does simplify the derivation of analytical MTF curves for certain cases.

The effect of fill factor on a square photosite (assuming that the active part of the photosite is just a smaller square centred in the outer square representing the photosite) is fairly straighforward: we are keeping the sampling rate the same, since the photosite pitch is unaffected, but we are reducing the size of the square being convolved with the incoming image. As a result, we would expect a lower fill factor to yield a better MTF curve, i.e., contrast will be higher than the 100% fill factor baseline. But it is still a good idea to test this, just to be sure ...


Implementing variable fill factors

Using the importance sampling algorithm described here, all we have to do is replace the square polygon representing the active area of the photosite with a smaller one, and we are done. The resulting PSF is thus the convolution of the photosite aperture and the Airy function (representing diffraction through the lens aperture). Unless otherwise stated, results were obtained at a wavelength of 550 nm, a photosite pitch of 4.73 micron, and an aperture of f/8, using a simulated system without an optical low-pass filter (OLPF), which appears to be all the rage lately.

MTF curve of Airy + square photosite PSF, at 100% and 50% fill factors
This result confirms our suspicions: if we decrease the fill factor by shrinking the square photosite aperture, the cut-off frequency of the low-pass sinc() filter is increased correspondingly (see here for an overview of diffraction and box functions). The MTF50 of the 50% fill factor sensor is ≈0.38, compared to an MTF50 of ≈0.34 for the 100% fill factor case.

So what are the downsides to using a smaller fill factor? Well, we are allowing substantially more contrast through above the Nyquist frequency (0.5 cycles per pixel), which will definitely increase the chances of aliasing artifacts (moiré, and/or "jaggies"). In the limit, we can imagine the fill factor approaching zero, which gives us a point-sampler, which will result in severe aliasing artifacts, such as the typical jagged edges we see when we render a polygon by taking only one sample at the centre of each pixel.

There is another effect that photographers care deeply about: noise. The relative magnitude of photon shot noise increases inversely with fill factor, since the photon shot noise is directly proportional to the active area of the photosite. The simulation above was conducted with zero noise, mostly to illustrate the pure geometric effects of the fill factor.

Speaking of geometric effects, a slight diversion into the interaction between edge orientation and photosite aperture shape is in order.

Square photosites are anisotropic

It is rather important to recall that an MTF curve is only a 1D cross-section of the true 2D MTF. If the 2D MTF is radially symmetric (e.g., the Airy MTF due to a circular lens aperture), then the orientation of our 1D cross-section is irrelevant.

The 2D sinc() function representing the MTF of a square aperture is not radially symmetric, hence the 1D MTF curve is only representative of the specific orientation that was chosen. The results in this post were all derived using a combined Airy and photosite aperture simulation; since the Airy MTF is radially symmetric, and the photosite aperture MTF is not, we can expect the combined system MTF to lack perfect radial symmetry. The question remains, though: is the combined MTF symmetric enough to ignore this matter entirely?

Feeling somewhat lazy today, I chose to evaluate this empirically, rather than deriving the analytical combined MTF at arbitrary orientations. Since we can directly simulate the edge spread function of a given PSF using mtf_generate_rectangle, I decided to vary the orientation of the simulated step edge relative to the simulated photosite grid, which is equivalent to taking our 1D cross-section of the 2D MTF at the chosen orientation.

Before we get to the results, first some predictions: We saw that the first zero of the sinc() low-pass filter of the square photosite aperture moved to a higher frequency when we decreased the fill factor. Intuitively, a wider photosite aperture produces stronger low-pass filtering. The length of the diagonal of a square is √2 × side_length, so we might expect a stronger low-pass filtering effect if the step edge is parallel to a diagonal of the square photosite aperture. And now the results ...
MTF curves of a square photosite (plus diffraction) at different edge orientations
Notice that there is a minute difference: the 45-degree edge orientation produced a slightly weaker low-pass filtering effect!
Subtracting the 45-degree MTF curve from the 0-degree MTF curve gives us a better view of the difference:
MTF difference between 0-degree edge and 45-degree edge
The difference certainly appears to by structured, and not in the expected direction. Well, certainly not the direction that I expected.

Fortunately the explanation is relatively simple. Consider the following diagram:
Representation of the area of the photosite (orange) covered by the step edge (blueish), for 0-degree and 45-degree edge orientations
If w represents the side length of our square, then the left-hand diagram shows us that the area covered by the 0-degree step edge is simply t × w over the range 0 < t < w/2. The right-hand diagram illustrates that the area covered by the 45-degree step edge (bluish rectangle) is √0.5 × t × t, over the range 0 < t < √0.5 × w (in both cases we only have to integrate up to the midpoint to study the behaviour in question). The area covered by the step edge can be plotted as functions:
We can see that although the 45-degree case starts out with a lead (the first part of the corner starts at roughly -0.2071 if we align them so that they reach an area of 0.5 simultaneously), the 0-degree case catches up near t=0.1. From that point onwards, the 0-degree step edge covers a larger part of the photosite aperture than the 45-degree step edge does. In practise, this means that although the 45-degree case is technically "wider", the 0-degree case presents a stronger low-pass filter. Keep in mind that on top of this rather small difference due to the anisotropy of the square photosite aperture, we are blending in the radially symmetric Airy MTF, which further suppresses the anisotropy.

The size of this effect is minute, as can be seen in the MTF difference diagram above. The MTF50 values are ≈0.3407 and ≈0.342 for the 0-degree and the 45-degree cases, respectively. In conclusion, we see that the anisotropy of the square photosite aperture is mostly masked by the strong isotropy of the Airy MTF at f/8. At larger apertures, the anisotropy is likely to be more apparent, but further analyses will be performed with a step edge orientation of 0 degrees only.

Approximating microlenses

It has been suggested that the microlenses alter the effective shape of the active area of a photosite. (For example, reader IlliasG contributed this info here). A regular polygon approximating a circle seems to be a reasonable starting point for simulating more realistic microlenses. Similar to the fill factor implementation, this merely requires swapping out the polygon used to specify the geometry of the active part of the photosite, and performing importance sampling as usual. (If you can point me at a more accurate description of the effective shape of the combined microlens and photosite aperture, I would be happy to incorporate that into MTF Mapper).

Before we look at the results, first a prediction: modelling the active area of the photosite as a circular disc, we should see a net decrease of the geometric fill factor, hence the low-pass filtering effect is expected to decrease. 

MTF curve of square photosite aperture (1x1) versus circular photosite aperture (radius 1)
No real surprises in these results. For a circular photosite aperture, I chose the inscribed circle to the square photosite, since this seemed more reasonable. Note that the fill factor of the circular photosite aperture is ≈78.4%, rather than the expected π/4 ≈ 0.7854, because I approximated the circle as a 60-sided regular polygon. So how much of the difference between the 100% fill factor square aperture and the 78% fill factor circular aperture is due directly to fill factor, and how much is due to the actual shape?
By subtracting the MTF curves as indicated in the legend of the plot above, we can see that, after matching the effective fill factor, the remaining differences are quite small. From the red dashed curve we can see that the circular (well, 60-sided regular polygon) photosite aperture behaves isotropically, whereas the 78% fill factor square photosite aperture still exhibits anisotropy (dashed blue curve).


Conclusion

I have not performed sufficient experiments to make any inferences regarding behaviour at larger apertures, but at f/8 on a 4.73 micron pitch, it definitely appears as if the geometric fill factor of the photosite is responsible for the bulk of the difference between a 100% fill factor square photosite and a 78% fill factor inscribed circular photosite aperture.

Once we match the effective fill factors, the difference between the square aperture and the circular aperture are of the same magnitude as the differences due to the anisotropy of the square aperture. At larger apertures, we should see more significant differences, but at f/8 the differences are not as significant as one might suspect.

I would like to revisit my D40 experiment armed with the new fill factor and photosite geometry functionality in MTF Mapper. Stay tuned for that!

MTF Mapper will include new options for controlling photosite aperture fill factor and shape from version 0.4.16 onwards, which should be released relatively shortly.

4 comments:

  1. Frans thanks for continuing this research.

    My "info" regarding the effective aperture shape was for spherical microlences.
    As there is continuous evolution in this field more complex shapes with special center-corner formation come in to production.

    The Suede gives an interesting effective aperture shape in his post http://www.dpreview.com/forums/post/51904462

    He can surely give you detailed info on this if you ask.

    ReplyDelete
  2. Thank you for the comment and the link!

    I approximated that shape, and repeated the simulations. A new post can be found here: http://mtfmapper.blogspot.com/2013/12/simulating-microlenses-kicking-it-up.html

    ReplyDelete
  3. Hi Frans,

    I am curious as to why MTFMapper would need to know the shape of the aperture or the pixel fill factor. Wouldn't the ESF, LSF and DFT be calculated exactly the same as always in order to generate the OTF?

    Jack

    ReplyDelete
    Replies
    1. Hi Jack!

      This article is about mtf_generate_rectangle, a synthetic image generation tool which is part of the MTF Mapper package. Fill-factors and photosite aperture geometries as important when you want to simulate a realistic image for a specific camera + lens configuration.

      These attributes (fill-factor, photosite aperture geometry) do not have to be known in order to apply the slanted edge algorithm to an image, in other words, your observation is spot on: none of this matters when using the mtf_mapper[.exe] tool.

      Of course, you will be able to measure the effect of these attributes on the ESF/LSF/MTF by first generating a synthetic image using mtf_generate_rectangle[.exe], and then passing the image on to the mtf_mapper[.exe] tool for analysis.

      Delete