Documentation

Veiling Glare AKA lens flare

News:  Imatest 5.0+  The Uniformity and Uniformity Interactive modules include ISO 18844 flare measurements.

 

Veiling glare is stray light in lenses and optical systems caused by reflections between surfaces of lens elements and the inside barrel of the lens. It is a strong predictor of lens flare image fogging (loss of shadow detail and color) as well as “ghost” images that can degrade image quality in the presence of bright light sources in or near the field of view. It occurs in every optical system, including the human eye.

Veiling glare can only be measured reliably from linear RAW images, converted to
16 or 48-bit files with gamma = 1. Processed images (JPEGs from cameras, etc.) handle dark tones
(critical to veiling glare measurements) in an variety of unpredictable ways that can affect results.

Lenses with low flare have been traditionally known for their excellent color performance. Color saturation is higher, especially in shadows. Low flare may be as responsible as sharpness for the exalted reputations of many classic Leica and Zeiss lenses. Even though reduced color saturation and contrast can be recovered with digital processing, lenses with low flare will always have an edge in quality, and flare is of particular importance in HDR (High Dynamic Range) imaging, where is the primary limiting factor for dynamic range. (HDR sensors with dynamic ranges greater than 120 dB— one million to one— are becoming commonplace, but the best lenses can’t come close.) There are several ways of dealing with lens flare.

  • In lens design, veiling glare is controlled by using high quality lens coatings (multi-layer coatings are best), baffling in the lens barrel, and careful design.
  • In the field it is mitigated by lens hoods and anything that can shield the lens surface from the sun. Ansel Adams used his hat, as well as a bellows lens shade, made famous in a Datsun (Nissan) commercial.
  • In the studio it is controlled by “barn doors” on light sources.

Veiling glare can be measured by the following Imatest modules.

  • Stepchart uses a Q13 or Q14 (linear) grayscale chart adjacent to the black hole. The grayscale chart is used to estimate the camera response (for processed images). It is always more reliable to use raw images.
  • Uniformity (and Uniformity Interactive) measure veiling glare using ISO 18844 method C in Imatest 5.0+. the image cannot contain a grayscale chart (linearization information must come from separate measurements.) Methods A and B, which require two chart images, will be added later.
Sun in image Sun blocked

Obligatory bad photo showing severe lens flare caused by the sun (far left), and moderate flare with the sun blocked (near left).
Canon EOS-20D, 24-70mm f/2.8L, 24mm, f/8, no hood.

Taken during Colorado’s notorious “Winter of 2007”
(five feet of snow in three weeks in December and January)

Imatest veiling glare measurements are designed to give a good prediction of a lens’s susceptibility to lens flare in challenging situations: the larger the number, the worse it’s likely to be. But it’s not a perfect measurement. It can’t predict ghosting (visible behind the Stop sign in the image on the left). And it is not reliable for processed images; only linear RAW images give reliable measurements. And RAW images are often not available for inexpensive cameras and camera phones.

The measurement is fairly simple to perform, but several pitfalls can cause inaccurate or misleading results unless measurements are made with care. Some degree of exposure control— either a manual setting or exposure compensation— is recommended for best accuracy. Exposure control may not be available with camera phones and other simple devices.

Veil measurement ideal

Veiling glare is measured by photographing one or more perfectly black regions inside a uniform white field that extends well beyond the image frame (1.41x the image width in ISO 18844). It is defined as the ratio of the light reaching the sensor from the black region (which emits no light) to the light reaching the sensor from the surrounding white field.

Veiling glare = V = L(black region) / L(white surface), where L is the illuminance at the sensor.

For linear image sensors (which includes most non-HDR sensors), this measurement is straightforward

  • if you have access to the linear (RAW) output of the sensor,
  • if the white area is unsaturated (ISO 18844 recommends a level of 225 out of 255 for files with bit depth = 8),
  • if the signal in the black region is large enough to be well above the noise, and
  • if the black region is perfectly black.

We deal with the last of these issues first: how to create a perfectly black object— a black hole (also called a light trap). Don’t worry: it’s more environmentally friendly than the type that sucks planets into its core.

Box for black hole

 

The “black hole” (light trap)

Veiling glare measurements from reflective charts with either Imatest Stepchart or Uniformity (the ISO 18844 type C measurement) require a completely non-reflective region (or regions). The darkest ordinary surfaces— materials or pigments— reflect about 0.5 to 1% of the incident light, i.e., they are are far from perfectly black*. To obtain a surface suitable for measuring veiling glare you will need to construct a surface that little light reaches— a black hole (light trap) — effectively the darkest possible region that can be photographed in a bright environment.

*Carbon nanotube-based surfaces come much closer to perfect black, but they’re
ridiculously fragile, and you can’t exactly buy them at your neighborhood camera store.

The black hole can be constructed inside a box or tube that is approximately 3x4 inches on its top (or 4 inches in diameter) and 4-8 inches deep. The bottom (inside back surface) should be lined with black velvet— the darkest material you can buy. The sides can be lined with any matte black material. We used black art paper because it was easy to work with. The top is a piece of black foam board with a 1x2 inch opening cut in the center.

The structure should be kept as lightweight as possible. If necessary it can be constructed entirely out of black foam board, with the black velvet in the inside back surface.

An alternative: A cone painted glossy black can be used to make a superior black hole.

Veiling glare with Imatest Stepchart

The black hole is mounted next to a standard step chart such as the Kodak Q-13 or Q-14, which allows you to measure the camera’s tonal response (pixel level as a function of scene luminance). This can help to linearize the image, but is not foolproof because cameras rarely have simple gamma (exponential) response curves (where pixel level = brightness(encoding gamma) ). Processed files from cameras frequently have nonlinear response in the bright regions, i.e., the response curve has a (film-like) “shoulder”— a good thing pictorially because without it digital cameras have a strong tendency to burn out highlights. They often deviate from a straight gamma response in deep shadows (which are more difficult to measure than highlights).

The Imatest Stepchart veiling glare method is very similar to Measurement type C described in section 4.3.2 of the ISO 18844 standard, described below.

In Stepchart, gamma (image contrast) for measuring veiling glare is calculated by one of several methods, and can be rather different from the average gamma shown in the figures.

No Veiling glare calculation (default)  
Veiling glare; gamma from darker zones (old) Used prior to Imatest 3.9. Inaccurate with subtle glare (a problem with the semigloss surface of the Q=13/Q-14 charts) reduces shadow contrast.
Veiling glare; gamma from lighter zones
Better if there are any problems with glare in the shadows, but not so good if there is a “shoulder” in the tonal response curve. Good with RAW files.
Veiling glare; gamma = 1 for RAW FILES!!! (best) Best with Bayer RAW files that have been accurately converted with gamma = 1. Beware of offsets, which can spoil the measurement.

Three additional settings allow the black hole to be adjacent to the white patch.

The white point is inferred from the region where the step chart pixel level is between 0.1 and 0.6 of the minimum-to-maximum pixel range, i.e., the brightest areas, which are frequently nonlinear (part of the tonal response curve “shoulder”), are excluded. The white reference is inferred from the patch in the middle of this region. For example, suppose it is patch 11. Since the Q-13/Q-14 has density steps of 0.1, patch 11 is 1.0 density units darker than (1/10 as bright as) patch 1, which is the reference white, i.e., we infer the white level from the measurement of patch 11: the inferred white pixel level would be (10 times the pixel level of patch 11)gamma. Since nonlinearities or even clipping of highlights is quite common, this technique results in a more accurate veiling glare measurement than you’d get by measuring the white region directly. Here is the modified veiling glare equation.

Veiling glare = V = ( Pixel level (black object) /Pixel level (white surface, inferred) )1/gamma

 

Assembling the target

 


Typical framing for measurements

For analysis with Stepchart a Kodak Q-13 or Q-14 step chart and the black hole box are mounted on a piece of mat board, roughly twice the width of the Q-13 chart— its dimensions are not critical. A 3/4x1 inch hole is cut in the mat board, just to the right of where of where the Q-13 chart will be mounted. The black hole box is mounted behind it. The Q-13 is mounted to slightly overlap the opening. The mat board is attached to a large sheet of white foam board with Velcro so it can be easily removed for safe storage.

Black hole detail

Black hole location detail

Veiliing glare target
The entire target

The black hole may be placed next to the white patch if desired– several settings have been added to allow for this placement.

Measuring veiling glare

  • Illuminate the target evenly, with no more than about ±20% variation in illumination across the target, as described in Imatest test lab. Keep the ambient light near the camera as low as possible ti minimize the light entering the “black hole.”
  • Note whether you are using a lens hood or a filter (like the ubiquitous UV filter most photographers leave on their lenses for protection). Both affect veiling glare.
  • Set the camera to the lowest available ISO speed to minimize the noise in dark patches.
  • Adjust the exposure (or exposure compensation) so the white level is close to saturation (around level 225 for 8-bit files), i.e., bias it in the direction of overexposure.
  • RAW output is strongly preferred, though JPEG may be perfectly fine if the response is reasonably close to a simple exponential (gamma curve); i.e., it does not have a complex tonal response curve, especially in the “toe” region). Unfortunately we’ve seen camera phones where this assumption completely failed. Here are the recommended dcraw settings:

Recommended dcraw settings for veiling glare measurements

Since dcraw does not always properly remove pixel (black level) offsets in the image file we frequently recommend converting raw files to DNG format, then reading them into Imatest.

  • Photograph the central portion of the target, leaving some white area around the Q-13 chart and “black hole.” Typical framing is shown above, to the right of Assembling the target. The length of the white target to the left and right of the frame should be about equal the frame itself. Similarly, the length of the white target above and below the frame should be about equal to the frame itself. (Light entering the lens from outside the image frame is an important contributor to lens flare.)
  • Run Imatest and select Stepchart. Open the image file. If Automatic Zone detection is unchecked and the image is the same size as the previous run you’ll be asked if you want to repeat the same ROIs (Regions of Interest). If you enter No, you’ll be asked to make an ROI selection. It’s OK to make a rough selection: another window will enable you to refine it.
  • After you’ve made the rough selection, the Stepchart input dialog box, shown below, appears. To measure veiling glare, Automatic Zone detection must be unchecked, the number of patches must be set to one greater than the number of patches in the step chart: 21 in this case, and Veiling glare must be set appropriately. For RAW images decoded according to the above recommendations, we recommend Veiling glare; gamma = 1.

Portion of Stepchart settings box, showing veiling glare settings.

  • Click OK. The fine adjustment box appears. Press Lighten, just to the right of Zoom out to view the dark patches clearly. The Lighten button changes to Normal when the image is in lightened mode. It also helps to maximize the window and click the Coarse radio button (middle, left).

Fine ROI selection
Portion of Fine ROI adjustment window; Lightened view ( Normal box is displayed)

  • Click Yes, Continue to run Stepchart and calculate veiling glare.

Results

The first illustration shows the results for the Canon EOS-20D with the 24-70mm f/2.8L lens set at 70mm, f/8. Veiling glare is shown on the middle-right of the first figure.

Results for Canon 24-70 lens with filter
with UV filter (not multicoated)

No filter
No filter: 23% lower veiling glare
Overexposed 2 f-stops
Overexposed about 2 f-stops, with UV filter:
Results are insensitive to overexposure.

These plots show the difference in linearity between JPEG and RAW (to TIFF) density response. The EOS-20D only deviates slightly from linearity (a straight gamma curve).

No filter
JPEG density response,
showing nonlinearity in highlights
Overexposed 2 f-stops
RAW/TIFF density response,
showing good linearity in highlights

 

Table of results: Canon EOS-20D JPEG data
Lens Elements Groups Focal length f-stop Veiling glare Comments
Canon 24-70mm f/2.8L USM (no hood; single-coated UV filter) 16 13 70 8 0.453% A premium zoom, known for excellent sharpness. Results are strongly affected by the single-coated UV filter, but they are insensitive to overexposure. When working from RAW (CR2) images, veiling glare was 0.564% with the filter and 0.391% with without it. Different results; similar trends.
” (no filter) 0.348%
” (overexposed 2 stops, with filter) 0.464%
Canon 90mm f/2.8 TS-E (no filter) 6 5 90 8 0.291% A very high quality tilt/shift lens with relatively few elements and groups. Has beautiful tonality and color quality. Low veiling glare expected.
Sigma 18-125mm f/2.5-5.6 DC (hood, multi-coated UV filter) 15 14 77 8 0.293% A remarkably fine lens for the price. Surprisingly low veiling glare. (If you’re thinking of buying one: it has poor autofocus performance; it’s much better on manual.)
Canon 28-80mm f/3.5-5/6 (no filter) 10 9 80 8 0.634% (1991 version) A cheap “kit” lens, designed for low cost. Expectations were low. Strangely reddish white balance.
Canon 70-200mm f/4L USM (UV filter, hood) 16 13 70 8 0.396% Excellent lightweight lens. The IS version has 20 elements in 15 groups, which will increase flare.
The table at the bottom shows the relationship between the number of groups (sets of attached elements) and the number of reflections that contribute to veiling glare.

Most of the results are not surprising. The Canon 90mm has the lowest flare, while the cheap Canon 28-80 is the worst. The only surprise is the excellent performance of the Sigma 18-125: a lens know for its fine performance and value, though its autofocus performance is mediocre. I use mine on manual.

Limitations

The veiling glare may be underestimated for telephoto lenses especially if they are measured without lens hoods because telephoto lenses form an image of only a small fraction of the light reaching the front element (the portion is much larger with normal and wide angle lenses). The target, as shown above, may not be large enough to simulate all the light that reaches the lens. If a hood is used, this error is considerably reduced.

If there are nonlinearities in the camera response at low light levels, the results may be incorrect (although relative results, i.e., comparisons, will still be valid). It’s always safest to work with RAW images and convert them with a “linear” (i.e., simple gamma curve) setting. You can read many RAW formats into Imatest, using the dcraw converter.

Lens elements, groups, reflections, and flare— some geeky math fun

Lens flare is closely related to the number of secondary reflections in a lens, i.e., light entering the lens that is reflected off one lens surface, then another, then back to the image plane. For uncoated air-to-glass surfaces, about 4% of the incident light is reflected. Simple coating reduces the reflection to around 2%; muti-coating reduces it to 1% or less. For a simple coating, the amount of the secondary reflection is 0.02 * 0.02 = 0.0004, which doesn’t seem like much until you calculate the number of reflections.
A lens consists of N elements in M groups, where a group may consist of several elements cemented together. It’s the number of groups M— actually the number of air-to-glass surfaces 2M— that really counts. The first surface has no secondary reflection. The second surface has 1: light that bounces off the second surface, then the first, then back to the image plane. Continuing with this reasoning, we see that the m(th) surface has m-1 secondary reflections, i.e., Total reflections = R = (2M-1) + (2M-2) + (2M-3) + … + 1 = M (2M-1) = 2M2M
If you add a filter to a lens with M groups, you increase the number of reflections R by 4M+1.
Groups
M

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Reflec-
tions R
1
6
15
28
45
66
91
120
153
190
231
276
325
378
Zooms typically have more elements than primes. Examples (easy to locate in the Canon Museum): The Canon 24-105mm f/4L IS USM has 18 elements in 13 groups. The Canon 50mm f/1.4 USM has 7 elements in 6 groups. The Canon 90mm f/2.8 TS-E has 6 elements in 5 groups. Now you know one reason primes are still used (others are large apertures, light weight, and excellent sharpness (MTF)), as well as why some photographers avoid using filters (though a UV filter is useful protection for field work).

ISO 9358

Veiling glare, as measured by Imatest, is similar to the veiling glare index (VGI) specified in the integral (black patch) test of the ISO 9358 standard. The key differences are

  • The ISO standard applies to lenses (optical systems), without including the effects of image sensors and image processing found in all cameras.
  • It calls for more rigorous testing conditions. In particular, an integrating sphere must be used. This means that there will be more light from outside the field of view, which will sometimes result in higher readings.
  • It does not include a grayscale step chart (for measuring tonal response) in the image. This means that only raw files (or files with extremely well-characterized tonal response (OECF curves) should be used. This is difficult to get right unless a camera raw image is available.
  • ISO 18844 (described below) was created to address some of the difficulties of making ISO 9358 measurements with cameras.

ISO 18844 flare (veiling glare) measurements
with Imatest Uniformity or Uniformity Interactive

ISO 18844 flare measurements have been added to the Uniformity and Uniformity Interactive modules in Imatest 5.0+. Currently, only Method C, which uses a single image where the dark areas are “black holes” (light traps) has been implemented.

ISO 18844 chart arrangements: either a single rectangle with dimensions 1/10 the image height and width (H and W)
or a set of circles arranged on a diagonal.

Imatest provides a backlit version of this test target. Transmissive charts should be used in a dark environment, taking care to minimize light reflected back to the chart.

The current ISO 18844 standard has one rather serious problem. In section 4.3.1 it gives an equation for linearizing the image (finding the output luma value Y’sYCC) using the equation for the sRGB color space, which is used in most consumer cameras. The problem is that most cameras do not encode their images according to the sRGB (or any other color space) standards. In fact they’re rarely even close. Most cameras apply tonal response curves (with “shoulders” to soften highlight saturation), and these curves may also affect response in the darker areas (critical to veiling glare/flare measurements) that can be difficult to measure.
Sample ISO 18844 flare image (simulated). Click to download
  • The first steps— illuminate the target through exposure and RAW settings are the same as for Stepchart.
  • Photograph the central portion of the target, framing it for H and V in the above diagram, making some adjustment for aspect ratio if necessary.
  • Run Imatest and select Uniformity or Uniformity Interactive. Open the image file. If the image is the same size as the previous run you’ll be asked if you want to repeat the same ROIs (Regions of Interest). In most cases you’ll select the entire image.
  • After you’ve made the selection, if you click Yes (not Express mode) the Uniformity settings window, a portion of which is shown below, appears. You can select between no ISO 18844 calculation or the calculation with two approaches to linearization: enter the gamma (shown below to the left) or use the color space linearization (called for in the standard, but rarely correct). Gamma must be measured in a separate image.

Uniformity settings window (portion)

Results

Results are in the ISO 18844 flare plot and in the CSV and JSON output files.

ISO 18844 Uniformity results for a simulated chart (not all diagonal regions were included)