Wednesday, 24 June 2015

Forensics - 'Cosine Fourth' Law of Illumination Falloff

Vignetting is the falloff of illumination in an optical system towards the edge of the image.  Birders who digiscope would be very familiar with Optical Vignetting which is caused when optical elements obstruct one another along the path to the sensor, and it can be very obvious for instance as a dark surround to the image if we fail to properly align the camera or phone with the scope eyepiece.   There are other causes of vignetting and one of them, referred to as Natural Vignetting or natural illumination falloff, is caused by a property of light and optics referred to as the 'Cosine Fourth' Law of Illumination Falloff.  

I have already explored Lambert's Cosine Law which makes the direct correlation between illuminance at a point on a surface and the angle of incident light hitting that point.  The cosine fourth law applies a similar principal and states that as the angle of light hitting a sensor or film plane diverges from the centre outwards (i.e. diverging from perpendicular to the plane) illuminance is reduced by a certain factor.  That factor is the fourth power of the cosine of the angle that the light makes to the perpendicular.

This has important considerations for photography, because unlike the retina of the human eye which is convex and doesn't suffer from natural vignetting, the film plane or sensor is flat, so potentially can suffer due to this problem.  As one might expect super wide-angle lenses are most prone to this problem because there is a relationship here with Angle of View.  Surprisingly the widest-angle lenses of all, fish-eye are immune to the problem due to curvilinear distortion (the same principal that applies to the human retina).

Of course like a lot of laws in optics this principal applies to a perfect system, but introduce other variables and real optical systems may behave differently.  There are various papers discussing these other variables including at THIS LINK.  In many cases it seems the degree of falloff observed in real optical systems may be more than predicted by the cosine fourth law alone.

For birders, the cosine fourth law is of virtually no significance because our lenses, be it binoculars, scope or camera all tend to have a relatively high magnification and therefore a low angle of view.  Considering that most DSLRs in mainstream birding are not full-frame cameras and therefore crop the edges of the image, the likely impact of this law is even lower.  Nonetheless it is important to be aware that the illumination of images is never totally uniform, especially when trying to carefully calibrate, measure and compare subtle tones.

Below I have mapped the angle of view of my Canon D70 and 300mm lens and overlayed the map on an image containing various gulls.

Friday, 19 June 2015

Forensics - Lambert's Cosine Law & Related Factors

While recently posting on Grey Scales and Gulls I referred to an earlier posting which I had made on Lighting and Perspective.  Writing on these kinds of topics I had arrived at the conclusion fairly quickly that lighting in a scene is influenced by the varying angles created between the light source, subjects and camera. I had already demonstrated this through experimentation using identical targets on a grid.  I hadn't actually explored some of the science behind it before now, and it is complex.  The principals are explained in part in Illumination Fundamentals, by the Lighting Research Center. 

Obviously birds are highly variable but occasionally we may be interested in comparing specific tones between multiple birds in the same image.  There are a few things to consider.  Firstly we have Lambert's Cosine Law which states that the illuminance (surface illumination, lumens/m2) falling on any surface depends on the cosine of the light's angle of incidence.  I have already used this principal in another posting establishing the direction to a light source in a photograph (HERE).  Because surface illuminance is highest when a surface faces the light source if we find the brightest point on a surface of our subject and draw a perpendicular line from that point (called a surface normal) the direction of that line indicates the direction to the light source (all else being equal).  For more on that subject please refer to that post.

However our digital image is formed not by the light illuminating the surface but by the light reflecting from it and entering our camera.  So we need to talk about reflectance.  Light hitting a surface is either reflected perfectly in one direction (specular reflection i.e. a mirror image) or it is scattered in numerous directions (Diffuse Reflection, i.e. most surfaces).  In the case of a perfect diffuser, or Lambertian Surface light is scattered equally in all directions.  Ideally our subjects would all have Lambertian surfaces.  That way we wouldn't have to concern ourselves with the relative angles between our subjects as they would look much the same from any angle.  But things obviously are not so simple.

While birds feathers tend to be quite matt in surface texture they are not Lambertian and therefore tones are influenced by both incident light direction and the angle of reflectance to the camera.  Beaks are often glossy in texture and even less ideally suited for direct comparison purposes.

Due to these principals we need subjects to adopt similar posture relative to the sun and the camera in order for us to make a meaningful comparison between them.  This doesn't happen very often in the field but gulls and other birds often face the same direction in a breeze at a tidal roost giving us some chance.  We still have a problem aligning our relative angles but there is a solution to this.

We can improve our chances of comparing surfaces meaningfully by closing the angles between our subjects.  As we get closer to our subjects our angle of view is increased, and conversely, the further away we are the narrower the angle of view.  Hence the digiscoped image of gulls above with it's extremely low angle of view (<<1 degree) offers a better comparison of mantle colour tones than an equivalent image taken with a 50mm lens kneeling right beside these birds.

Calculating angle of view is not difficult provided the lens is rectilinear (i.e. not spatially distorted, such as a macro or fish-eye lens).  The equation is angle of view = 2 arctan d/2f where d is a dimension of the film sensor (vertical or horizontal) and f is the effective focal length of the lens.

I worked out these values for my camera and lens configuration and created a map for the angle of view which I can slot an image into, so now I can roughly gauge the angular distance between birds in my images.  The Laughing Gull (Larus atricilla) below is just off centre.  The Herring Gull (Larus argentatus argenteus) to it's left is approx. half a degree separated and the Black-headed Gull (Larus ridibundus) flying to it's right is 1 degree separated.  The adult Herring Gull standing on the harbour wall, at a different angle relative to the camera is just under 1.5 degrees separated from the Laughing Gull.  Obviously this tool is only really possible with a fixed lens as it can be hard to calibrate with a zoom lens or a digiscoping arrangement where both the zoom setting of the camera and scope are liable to change.

One further note of caution with all of this of course is vignetting.  Vignetting includes the 'cosine fourth' law (natural vignetting).  It also includes for instance to lens design (optical vignetting), often a feature of digiscoping as in the image above.  Vignetting adds to the difficulty and complexity of lighting in digital images.

Sunday, 14 June 2015

Field Marks - Grey Scales and Gulls (Part 1)

The Kodak Grey Scale is commonly used as a tool in gull identification.  It is a luminance scale with just 20, equally spaced increments, or levels between white and black.  For birds in the hand it is a very useful scale.  The human eye is good at making accurate direct (or local) tonal comparisons, so by placing a grey scale card directly on top of a grey mantle or wing feather of a gull we can easily make this direct comparison and assign a Kodak grey scale number to that tone.  Crucially, this can be done irrespective of ambient light quality because the lighting at that point on the bird matches the lighting on the card.  Table 3 in page 26 of Gulls of the Americas by Howell and Dunn lists the typical Kodak grey scale numbers for various gull species and taxa.  These numbers are quoted elsewhere throughout the gull identification literature, so this has become a recognised standard in gull research.

A Digital Grey Scale Equivalent
It is very simple to make a comparable grey scale for digital images.  We know that black has a luminance of 0 and white a luminance of 255.  So we need only space 18 tonal increments evenly between these two points to make an accurate scale for use within the digital sphere.  From this point on however things get progressively more complicated.  The problem we have of course is how to accurately superimpose our grey scale into each of our digital images.  The tonal levels in our images afterall are subject to a range of variables and it can be a real challenge to accurately depict individual tones.

We may be able to assign say a Kodak grey number of exactly 8.0 to a specific feather of a Laughing Gull (Larus atricilla) by comparing it to a Kodak grey scale card in the hand.  If we then were to photograph the bird moving about in various lighting settings we could quickly find that this specific feather is capable of varying in luminance level from near 0 (19 in our scale) when say the bird is in deep shade, to near 255 (0 or A in our scale), were the sun to reflect brightly off the feather for instance ... and every tonal level in between.

In the example below the mantle of this Laughing Gull is a shade darker perhaps than it appeared in life and this is simply due to the exposure and/or brightness settings of the image.  Brightening the image just slightly would resolve this discrepancy.  The European Herring Gull (L. argentatus race argenteus) behind it is also displayed a shade too dark and may also fall into line with the help of some brightening.  To further compound the problem the choice of sample point is critical.  Sampling a shaded part of the scapulars of the Herring Gull results in a grey scale value of 12, i.e. darker than the Laughing Gull sample.  We would expect a grey scale level of between 4 to 5 for L. a. argenteus based on the Kodak scale and of course we can see without even having to sample that overall the Herring Gull is on the whole paler than the Laughing Gull, as it should be.  So a bad choice of sample point renders this method ineffective.

So we have identified a few confounding factors that would need to be resolved in order to apply the grey scale method to a digital image.
These include:-
- Ambient lighting quality
- Image exposure quality
- Image brightness and contrast settings
- Choice of sampling point

Brightness, Contrast and Dynamic Range
Image brightness is determined by camera exposure settings and also by the processor during the output of the final image.  Contrast is influenced by scene lighting and dynamic range, but also by exposure and again the camera's processor when outputting the final image.  These elements have the strongest influence on the accuracy of tones in our images.  We can adjust brightness, contrast and use other tonal adjustment tools both in RAW and when post-processing images but we have no way of matching tones exactly without some form of reference.

Our eyes have an amazing dynamic range (the range of luminance which our eyes can adapt to).  This means that we could be gauging the mantle colour of a gull against a Kodak chart under almost any lighting conditions and we would make a pretty good job of it.  Cameras do not have the same dynamic range as our eyes.  Let's say for example we take an image on a very bright day with broad dynamic range.  In that instance some of our tonal range may have been lost due to clipping.  The pale grey on the mantle of a Herring Gull may be blown and appear white in an image.  Alternatively the black of the wing may not appear pure black and this might influence the accurate capture of a species like Great Black-backed Gull (Larus marinus) or Kelp Gull (Larus dominicanus).  With bright sunlight and broad dynamic range the contrast between shadows and highlights is also enhanced.  The mid-tone range is diminished which can obscure the correct tone of a mid-toned gull species.  

Ambient Light and Reflectance
What we are trying to measure here specifically is the reflectance of these feathers.  The camera is equipped with an on-board light meter and this is quite an accurate instrument.  The problem for us is that the light which the meter measures from our subject is reflected light - i.e. a combination of the ambient lighting of the scene and the reflectance of the feather.

Furthermore automatic exposure is based on metering and the exposure is intended for a reflectance of approx. 18% grey.  Put another way, camera exposure technology is still pretty unsophisticated - by assuming everything in the world is this pale grey it is not too surprising that tones are often out of step with reality.  For more on metering see HERE.

If we want to get at the true reflectance of the feather we need to decouple ambient light from reflectance in our measurement.  The only way to do this is to measure the ambient light separately and correct the image brightness based on that.  For this we either use a light meter or a grey card.

Lighting and Perspective
In reality it can be very difficult to obtain the exact light reading we are after.  Considering that we are dealing with a three dimensional subject where even the slightest change in the angle between the light source, the subject and camera will influence tone, this is not an easy thing to get right.  We also have to consider that an exposure calibration will only correct for the lighting in a certain plane within the image.  If we need to compare a number of subjects in the same image, all at different distances and facing the light source from different angles, the lighting will vary in all these locations.  I have illustrated this point in an earlier posting on Lighting and Perspective as also shown by experiment below.

I have studied lighting and perspective in more detail HERE.

Sample Point
A spot sampling technique is explored HERE.  Knowing where to sample is the problem.  Immature gulls begin to accumulate adult-like plumage from their 1st winter.  The mantle feathers are the first to develop large areas of grey and being positioned at the highest point on the body are also the most reliably lit so this would tend to be the best place to sample.  Take a look at the collection of images at the end of this post.  It should be obvious that the upper mantle is the most consistent location to obtain an appropriately representative grey scale sample.

Grey Scales Versus Hues
Note again the grey scale is a luminance scale only so colour hue and saturation are irrelevant in this comparison.  Clearly hue does have a role to play in gull identification but not for this particular analysis.  If you are finding the subtle differences in hue between gulls a little jarring simple convert your images to grey scale and compare them along the grey scale in that way.  I haven't done that here because I want to specifically draw attention to the fact that most gulls are not grey as such but a range of low saturation blues and browns.  These subtle colours may turn out to be just as important in ID terms as the luminance level but shall be treated separately.

In Summary
Clearly, with the variables we are dealing with, trying to accurately depict and then measure the upperparts tones of gulls is a real challenge.  For the best results we need bright but overcast conditions, we need to obtain a good exposure without clipping and we need to carefully measure and correct for the ambient light using a grey card or handheld light meter.  Last but not least, our choice of sample point is crucial.  We need to avoid the influence of bright reflection and shadow, and if we hope to compare different subjects in the same image we must ensure we sample from very similarly lit points.  The upper mantle would seem to be the best location in general to sample from.

For more on Grey Scales and Gulls...

Field Guides - Photographs Versus Illustrations
Lastly a comment on photos versus illustrations.  I find the illustrated plates in Malling, Olsen and Larsson's Gulls of Europe, Asia and North America easier on the eye and easier to interpret than the photographic plates in either of these two leading gull reference guides.  Lighting, exposure and white balance can be very distracting in many photographs, especially when one's eye is tuned to look for these image quality parameters.  It can be hard in some cases to readily appreciate the correct tone of a bird's upperparts from a photograph particularly when faced with these additional cues.  Furthermore a grey scale contains no hue and yet clearly gull species differ slightly in terms of the hue of their upperparts, with some species showing warm earthy tones and others tending towards the colder blue-greys.  For me Larsson's excellent plates convey both the subtle luminance and subtle hue more effectively than a range of photographs can.  So, my preference in this case would be for the illustrations.

Wednesday, 10 June 2015

Forensics - Maximising Image Sharpness

There are a number of different factors influencing image sharpness.  I have covered various aspects of image sharpness in a few postings in the blog but I haven't pulled them all together in one place.

Focus is one of the parameters used in the Image Quality Tool.  HERE I have it summarised.  

Clearly the resolution of the sensor has a function in image sharpness as detailed HERE.  Acutance is the impression of sharpness created by contrast.

Creation of a full colour image from a RAW Bayer image involves interpolation which reduces the overall sharpness of the image as discussed HERE.

I discussed the concept of an Airy disc HERE.  If we consider the focus of a discrete point of light by a lens, an Airy disc is considered the sharpest possible image by an ideal lens.

Putting all these concepts together makes for a rather complex subject matter but the experts at Cambridge in Colour have produced another excellent tutorial entitled Lens Diffraction & Photography which takes these and other related parameters and provide what is effectively a guide to obtaining the sharpest possible images from our camera equipment.  Part 2 of the tutorial can be found HERE.  Perhaps the most interesting concepts are the distinction between Artefact-free and Extinction Resolutions and also the fact that higher aperture can result in lower image sharpness (diffraction limit).