News: October 2021: A new method using two exposures (without and with a special mask) provides an excellent measurement of veiling glare as well as two flavors of dynamic range. February 2018: Imatest presented a paper, “Measuring the impact of flare light on Dynamic Range,” at Electronic Imaging 2018. It can be downloaded here. Imatest 5.0+ The Uniformity and Uniformity Interactive modules include ISO 18844 flare measurements. |
Related pages Stray light (Flare) – The small, bright light source approach to stray light testing reveals other forms of stray light (not limited to veiling glare). Dynamic Range a comprehensive introduction: strongly affected by flare light. Contrast Resolution – A special transmissive chart for measuring the visibility of low contrast features in larger fields over a wide dynamic range Making Dynamic Range Measurements Robust Against Flare Light |
Introduction to veiling glare | Lens reflections | “Black hole” light trap | I. Stepchart measurements
II. ISO 9358 | III. ISO 18844 | Gamma recommendations | IV. Contrast Resolution two-exposure method
Quantifying Veiling Glare | Two image calculation
Introduction
Veiling glare is stray light that fogs images (reduces contrast in shadow areas). It is caused by reflections between surfaces of lens components 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. It is a major factor in limiting camera dynamic range, especially when High Dynamic Range (HDR) sensors, which have sensor dynamic ranges of 120 dB or more, are used.
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 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 classic Leica and Zeiss lenses.
This statue near the entrance to Parc du Cinquantenaire in Brussels (the location of the autumn AutoSens conference) knows how to deal with flare light by shielding her eyes from the sun.
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 a bellows lens shade, made famous in a Datsun (Nissan) commercial. (Here is some background information. I remember Adams’ Ford with “Zone V” license plates). He used his hat in a pinch.
- 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.
- The Image Statistics module is valuable for examining spatially-dependent lens flare, as illustrated below.
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.
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.
Lens reflections are a major cause of flare light. An uncoated glass surface (index of refraction ≅ 1.5) reflects R = 4% = 0.04 of the light incident on it. (Remember, a sheet of glass or a lens component has two surfaces.) For each glass surface between any surface and the light source, a fraction R of the primary reflection (R2 of the original incident light) is reflected back to the image sensor. This are called a secondary reflection. Since most lens surfaces are curved, this light will be unfocused, i.e., it will tend to fog a portion of the image. According to Edmund Optics, the best anti-reflective coatings have R ≅ 0.4% = 0.004 over the visible spectrum (~400-700nm). R = 0.005 may be more realistic for a reasonable range of incident angles. The light reflected back to the sensor from each secondary reflection would be R2 = 0.000025 = 2.5*10-5 = -92 dB (20*log10(R2)). The number of secondary reflections Nsec increases rapidly with the number of components M (groups of elements cemented together, each of which has two air-to-glass surfaces) in a lens: 1 for 1 component; 6 for 2 components; 15 for 3 components; 28 for 4 components; 45 for 5 components, etc. For M components, \(\displaystyle \text{Number of secondary reflections} = N_{sec} = \sum_{i=1}^{2M-1}i = 2M(2M-1)/2 = M(2M-1))\) M = 5 components are typical for high quality camera phones; M ≥12 components is commonplace for DSLR zoom lenses. Overall lens flare is less severe than the number of secondary reflections suggests because the stray light don’t cover the whole image. It decreases with distance from bright regions. It’s easy to see why practical camera Dynamic Range measurements are limited to around 70-90dB, even when sensor Dynamic Range is much higher. Because the ISO 18844 model does not measure the spatially-dependent flare caused by lens reflections, it’s value in characterizing practical system performance is limited. |
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.
I. Veiling glare with Imatest Stepchart
This method is no longer recommended. It has been replaced by ISO 18844, or,
for higher quality measurements, the Contrast Resolution two-exposure method.
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 location detail
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 to 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 . 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 , 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.
VG, Cavity on Left means that the cavity is adjacent to the white patch on the left of the chart image. It does not mean that the image has been flipped (mirrored) horizontally. |
- Click . The fine adjustment box appears. If the dark patches are too dark, press , just to the right of to view them clearly. The button changes to when the image is in lightened mode. It sometimes helps to maximize the window and click the radio button (middle, left).
Portion of Fine ROI adjustment window; Lightened view ( box is displayed)
- Click 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.
with UV filter (not multicoated)
No filter: 23% lower veiling glare |
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).
JPEG density response, showing nonlinearity in highlights |
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.
II. 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.
III. 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 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 or . 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)
- Choose a “black hole” detection method: “auto” or “from manual threshold“
- Auto (recommended): Applies adaptive thresholding to the image to determine what pixels constitute black hole areas. Less likely to be fooled by vignetting than a manually-set global threshold value.
- Manual Threshold : When this option is selected, the field to the right is enabled and the user may enter a numeric value between 0 and 1. Linearized pixel values (normalized to the data type range, so that they area between 0 and 1) below this threshold value will be indicated as black hole areas.
- Select the “Flare plot” to have the figure generate.
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)
Black Hole Detection Problems
Imatest uses a few criteria beyond the thresholding option (auto or manual) described above to determine what is a valid area for producing ISO18844 flare results. If you are testing an image and the software appears not to be operating on a black hole area in it (i.e., it is greyed out in the output plot and shows no measurement numbers), there may be a few reasons why:
The black hole area is too small : In order to prevent spurious results, we require that areas that pass the thresholding test also have a large enough contiguous area to be useful. This involves eroding in from the sides of the detected area, so if your black hole is too small in the image (which may happen with low-resolution cameras at a large distance from the target), it may not appear in the results.
The black hole is not surrounded by enough light-area data : Method C of ISO 18844 requires that the pixel value in the black hole area be compared to the pixel values in the locally surrounding light areas. Moreover, it averages the light area values from regions from all four sides of the black hole (above it, to the left of it, etc.). If there is not valid light-area data within an appropriate margin on all four sides of the black hole area, it will not be measured. This can happen when the black hole is too close to the edge of the image/crop area or too close to another black hole.
IV Contrast Resolution two-exposure method
In 2021.2 we added support for a new combined dynamic range and image flare (veiling glare) measurement made from two images of the Contrast Resolution chart: one acquired without a mask and one with a mask. In addition to veiling glare, this method measures two dynamic ranges: one with normal flare (no mask) and one with low veiling glare (masked), and provides additional information on the specific factors that limit dynamic range. The mask greatly reduces veiling glare by covering 86% of the lighter patches (1-12), leaving only the small lighter and darker inner regions. It also covers most of the remainder of the chart. Darker patches 13-20 are unmasked. An image of the mask, which fits tightly in the frame that holds the chart, is shown on the right, below. The circular openings (for the registration marks) are covered by neutral density gel filters with an optical density of 1.2 to minimize flare and (in most cases) allow automatic region detection.
Contrast Resolution concept chart | Contrast Resolution flare mask |
Method
Acquire two images of the Contrast Resolution chart, identically exposed and framed, one without the mask and one with it.
Exposure— For linear sensors, the exposure should be set (if possible) so the lightest inner square in patch 1 is saturated, but the darker inner square is not. We will add a recommendation for HDR (nonlinear) sensors when we gain more experience. Manual exposure control is strongly recommended. Autoexposure should be avoided because most autoexposure algorithms tend to overexpose the brightest patches in masked images, often severely.
Framing— We generally don’t recommend filling the frame with grayscale/dynamic range test charts. (Filling the frame is only appropriate for multi-purpose charts like SFRplus or eSFR ISO.) A good guideline for medium to high-resolution cameras (≥5MP) is that the vertical dimensions of the chart should cover about half the image. Since veiling glare is dependent on the spacing between the lightest and the measurement patches, framing In any test sequence should be consistent to ensure measurement consistency.
Imatest automatically detects the mask and adjusts the calculations accordingly
The signal level, which is calculated from the left side of the lighter patches (1-12) in unmasked images, is replaced by the mean of the two smaller (lighter and darker) inner squares in masked images. The noise is calculated from one of the two squares (the lighter square, except for the top row, which can saturate). Most of the results are similar with and without the mask, except in the darkest regions. Since the mask greatly reduces veiling glare, the mean of log pixel levels in the dark bottom row (patches 18-20) is reduced. Veiling glare is the difference in the log pixel levels in the bottom row measured without and with the mask.
Results
We illustrate the two-exposure method with images from the Panasonic Lumix LX-100— a relatively compact high quality consumer camera with a 1 inch (linear; non-HDR) sensor and a high quality Leica-branded zoom lens that can save raw files (vital to the success of this measurement). Exposure control was manual, 1/60 sec., f/8. Three types of file were analyzed
- Raw files were converted to 48-bit color TIFF files (bit depth = 16) using LibRaw (the replacement for dcraw), which has no sharpening or noise reduction. Two gamma settings were analyzed.
- files converted to Adobe RGB color space with encoding gamma = 1/2.2, and
- files converted with gamma = 1 (unchanged from the raw image).
- JPEGs (24-bit sRGB color), generated inside the camera. Noise reduction and sharpening (bilateral filtering) are applied, and the tonal response curve is quite different from a straight gamma curve (pixel level proportional to brightness(encoding gamma)).
Raw to 48-bit color Adobe RGB (bit depth = 16; encoding gamma = 1/2.2)
This conversion gave the best results. Using gamma = 1 (described below) causes measurements to be limited by bit depth = 16, which has a maximum pixel level of 216-1 = 65535, where log10(65535) = 4.816 = 96.3 dB. As we point out in Gamma, Tonal Response Curve, and related concepts — Advantages of gamma-encoding, gamma-encoding (typically with γ = 1/2.2 = 0.454) significantly increases the effective dynamic range, greatly improving these measurements.
This conversion encodes the input image with a nearly pure gamma = 1/2.2 curve. If there were no veiling glare or noise, the response curve (the thick gray line in the plot below) would be a straight line with slope = 1/2.2 all the way from the lightest to the darkest patch. A flattening of this curve in dark regions indicates the presence of veiling glare (and possibly a noise floor).
The key results are on the right side of the upper graphs of each image (the font is somewhat small in the images below): Y(patch 1, mean(18-20)) is the log10(luminance) level for patch 1 and the mean of the dark patches in the bottom row. This value is strongly influenced by flare light, as indicated by the flattening of the log10 signal level curve in the upper plots.
Adobe RGB (48-bit) results without mask.
Patch 1 = 0; mean Y(patch 18-20) (bottom row) = -2.04 (log10 units) Adobe RGB (48-bit) results with mask.
Patch 1 = -0.027; mean Y(patch 18-20) (bottom row) = -3.53 (log10 units)
Quantifying veiling glare
Since the density of the gray areas increases by 5 dB = 0.25 OD per patch, the mean density of the bottom row (equivalent to patch 19) is 18×5 = 90 dB = 4.5 OD, equivalent to patch 19 illumination = 0.0000316 (linear units) relative to patch 1 (the brightest patch on the upper-left).. For a γ−enc = 2.2 color space, this would result in Plog(19) = log10(pixel level(19) ⁄ pmax) = 4.5/γ−enc = −2.04, which is higher than we often observe. If Plog(19) is lower for either of the images (it’s -2.04 and -3.56 for the images above), we assume that the camera is not sufficiently linear to calculate veiling glare from a single image, and we have to use the 2 image method, below.
The measured log pixel level for normalized illumination In on patch n is affected by the encoding gamma γ-enc.
pixel level(n) ⁄ pmax = In γ-enc for patch n, where pmax = the maximum pixel level for the bit precision (255 for 8-bit files; 65535 for 16-bit files, etc.)
For Adobe RGB color space (used here), γ-enc = 1/2.2 = 0.4545. sRGB is close but not exact (it has a small linear region.) Note that in-camera JPEG files apply all sorts of tonal response curves, making γ-enc difficult to determine. For γ-enc to be a reliable, known value, you must start with raw images and use a raw conversion program (such as LibRaw, used in Imatest) that uses a simple gamma curve without any additional processing like “shoulders” or tone-mapping. Log pixel level, displayed on the plots, is
Plog(n) = log10(pixel level(n) ⁄ pmax) = γ-enc × log10(In) ; In = (pixel level(n) ⁄ pmax )1/γ-enc = 10^(Plog(n) ⁄ γ-enc)
For patch 1 (the brightest patch on the upper-left) we can assume that I is entirely from the chart (I1-total = I1-chart ), but for the mean of patches 18-20 (i.e., patch 19), where the chart has an average density of 4.5, corresponding to a level off 0.0000316 (linear units) relative to patch 1 (I19-chart = 0.0000316 I1-chart), we assume that I19−total is the sum of illumination from the chart and from veiling glare,
I19-total = I19-VG + I19-chart = I19-VG + 0.0000316 I1-chart ; I19-VG = I19-total – 0.0000316 I1-total
We don’t want an absolute number. We want the veiling glare measured on the mean of patches 18-20 relative (normalized) to the illumination on patch 1. For brevity we call it VG19.
VG19 = I19-VG / I1-total = I19-total / I1-total – 0.0000316
VG19 is calculated in several steps from the above equations, starting with Plog(1) and Plog(19), using I1-total and I19-total as intermediate calculations. It should be a reasonably good number for linear sensors where γ-enc is known and consistent, but we have not found it to be reliable in practice. For the masked image above, I19-total is much lower than expected for patch 19, assuming good linearity and γ-enc = 1/2.2. For this reason measurements with 2 images are more reliable.
Two image calculation — Because camera linearity may not be what we expect (as we found for the above example), a better estimate of veiling glare is the difference in VG19 from two images, where we ignore the expected 0.0000316 value ffrom patch 19. VG19 = I19-total / I1-total .
VG19(2 images) = VG19(no mask) –VG19(masked)
= I19-VG(no mask) / I1-total(no mask) − I19-VG(masked) / I1-total(masked)
If With manual exposure control (required for good results), I1-total(no mask) ≅ I1-total(masked), but it’s easiest to measure them in the individual images.
For the image with no mask,
The difference in the results — -2.04-(-3.53) = 1.49 log10 pixel units — is an indicator of veiling glare, though it’s the primary measurement. Since the image was encoded with gamma = 1/2.2 (0.4545) (close to the measured value of 0.458), the actual flare difference is 1.49×2.2 = 3.28 density units. Note that the relative mean level of the patches in the bottom row is log10-3.53 = 1/3388.
A little more math The nominal density for each of the twenty large patches in the Contrast Resolution chart increases by 5 dB (0.25 density units) per patch. The darkest patch is 95 dB (4.75 density units) below the lightest, equivalent to 1/56234 = 0.00001778. If a system were exactly encoded with gamma = 1/2.2 (perfectly linear in log space), the darkest patch would have log10(pixel level) = 4.75/2.2 = 2.16. Since this is not what we measure, we have to conclude that the system (hardware or LibRaw software) does not follow the gamma = 1/2.2 curve exactly in the dark regions. The mean luminance (Y) values for the bottom row without the mask in linear units is 10-2.04 = 0.00912 = 1/109.6. The mean luminance (Y) values for the bottom row with the mask in linear units is 10-3.53 = 0.000295 = 1/3388. This level is due to signal from light passing through the chart, noise, and veiling glare from the bright part of the masked image (much less than for the unmasked image). A good measure of veiling glare is (the level of the darkest row in the unmasked image minus the level in the masked image) divided by the level of patch1, which should be exposed close to saturation. If we assume that these numbers are additive, we can subtract the masked level to find the veiling glare level. Veiling glare level = 0.00912 – 0.000295 = 0.008825 = 0.8825% (linear units) = -2.05 (log10 units). |
Raw to 48-bit color (bit depth = 16; linear encoding: gamma = 1)
The gamma = 1 results appear similar to the gamma = 1/2.2 results (except for the larger slope: measured gamma = 0.847), but the numbers were different. Mean Y (patches 18-20) = -3.86 without the mask and -5.32 masked. The difference between the two results, 1.46 density units, is similar to the difference for gamma = 1/2.2, but this is less than expected. Based on the gamma = 1/2.2 results we would have expected a difference of around 1.46×2.2 = 3.2.
What appears to be happening is that log10(pixel level) drops below -5, which is 10-5 = 1/100,000 in linear units. This is beyond the expected range for 16-bit depth images, where the maximum pixel value is 65535, i.e., the limit of the linear 16-bit depth file has been reached. The histogram on the right shows pixel levels in a dark portion of the masked image. Many pixels, particularly in the green channel, are zero. Note that this is for a 16-bit file, which has a maximum level (x-axis value) of 65535.
JPEG (24-bit color; bit depth = 8; encoding gamma approximately 1/2.2)
JPEG files are processed inside the camera. Processing includes noise reduction (which accounts for the larger noise-based dynamic range than the 48-bit Adobe RGB conversions), sharpening, and the application of a tonal response curve in addition to gamma-encoding. The tonal response curve is not straight: it has a strong “shoulder” at bright levels, which makes the image appear more “film-like” and helps to minimize saturated (burnt-out) highlights.
For both the unmasked and masked JPEG images, the response curve flattens out around input density = 3 to a log10(level) of around -2.3 (10-2.3 = 1/200. Mean Y (patches 18-20) is -2.19 without the mask and -2.24 with the mask. Sad to say, the 2-image veiling glare measurement fails for the 8-bit JPEG image. 🙁 The 16-bit Adobe image (encoding gamma = 2.2) works best.
JPEG (24-bit) results without mask.
Patch 1 = 0; mean Y(patch 18-20) (bottom row) = -2.19 (log10 units) without the mask
and -2.24 with the mask. The measurement failed because of limits of the 8-bit image.
A deeper dive into veiling glare: why the bottom row reverses direction
A strange anomaly is visible in the bottom row (patches 18-20) of the above images: log density starts increasing, when it should be decreasing. To observe the deep shadows, we opened a heavily overexposed capture of the masked chart in Image Statistics (1 sec. vs. 1/60 sec. nominal exposure: 60× the exposure), then displayed it using Lighten (HSL) to makes deep shadow detail visible. The 7 lightest patches are fully saturated.
Short-distance flare, as described in the Dynamic Range post and measured by ISO 18844, is plainly visible.
Something surprising but not entirely unexpected is happening in the bottom row: smudges that get lighter as we move from patch 18 to 20 (from dark to darker). These smudges appear to be radially-symmetric highly-blurred replicas of the light patches in the first row, indicated by the red arrows pointed from the source of the smudge to the smudge itself. This phenomenon is uncommon, though we’ve seen it in one other camera.
It is interesting to compare it with a 30× overexposed unmasked image, also HSL-lightened. Lots of veiling glare is visible.