I've been researching lens bokeh... and I'd like your help collecting sample PSFs.

An image is formed by a lens as the sum of the PSF (point spread function) for each point of light in the scene. The PSF shape usually is too small to be obvious for points in focus, but typically is magnified in the out-of-focus portions of images, creating the characteristics known as bokeh. The PSF of each lens is a little different, and PSF also vary with focus, aperture, position within the frame, zoom focal length, etc. However, the PSF of a lens easily can be sampled by setting manual focus as close as possible, aperture wide open, and photographing a centered distant point light source (e.g., a white LED at 10m) on a dark background.

For example, my 50mm f/1.4 SMC Takumar has the PSF shown in the first image. The bright center with darker edges is why you get such smooth bokeh from this lens.

In comparison, the second (smaller) image is from a 28mm f/3.5 Super Takumar. The brighter edges leave sharp line artifacts in the bokeh.

PSFs are very sensitive to various lens properties and defects. For example, the third image is the PSF from a 50mm lens which looks & works fine, but has a minor fungus problem. Yes, that's really a minor fungus problem... the kind you wouldn't even notice on the glass if you were not looking for it, and certainly wouldn't see in a sharp-focus photo.

Some of my group's current research at the University of Kentucky (Aggregate.Org: Digital Imaging Technologies) involves using knowledge of the PSF image to do many things, such as 3D image capture using depth-from-defocus. I need lots of real lens PSFs in order to be able to parametrically describe bokeh/PSF features....

How you could help. What I'd like to see for this research is cropped PSF images, like those attached, from as many different lenses as possible. For each, it also is important that I know what lens it came from and any lens defects that you know are present. If you wish, it also might be interesting for people to see an ordinary photo taken with the same lens (and aperture setting) that shows the bokeh in a more normal context....

Thanks.

PS: I'll assume that posts in response to this thread are by the owners of the images posted, and that it is OK for me to use these images, with acknowledgement, in research publications.

However, the PSF of a lens easily can be sampled by setting manual focus as close as possible, aperture wide open, and photographing a centered distant point light source (e.g., a white LED at 10m) on a dark background.

I'm guessing that the bokeh images you presented are very small bits of the whole image. Presumably the futher out of focus, the larger the PSF pattern so using extension rings will make the PSF pattern bigger and the sample more accurate. I will have a go at this as it look like an effective way of testing the cleanliness of lenses in addition to determining their PSF. If I get any usefull looking sampes I will post them for you use.

The pixel dimensions of the PSF largely depends on the focal length, aperture, and sensor pixel pitch as well as the focus distance. For a typical fast 50mm on an APS-C DSLR, the PSF isn't all that small. A close-focus 500mm f/6.3 mirror lens gave a PSF filling the APS-C frame! Slow wide-angle lenses can have tiny PSFs.

You'll also want to watch the exposure. Although the PSF may be a small fraction of the frame, expose for it, because we want to see what's inside it.

If it comforts you any, it isn't as easy as it sounds. If it were, I wouldn't call it research.

Using my current approach, it would take many hours on a supercomputer to compute a reasonably accurate map of a single image using the PSF data. Fortunately, I have a supercomputer... well, several, actually . Also, the PSF data need to be sampled at the taking aperture and, for many lenses, the PSF changes in various ways as you get away from the center of the image, in which case multiple PSF samples must be taken across the frame. The PSF also differs in front vs. behind the focus distance, and some lenses even change characteristics significantly just by changing the focus distance. There also can be lens flare and internal reflections, sensor noise, etc. muddying the analysis of any given image. When I'm sure the PSF/bokeh model is good enough, I'll worry about making it faster to execute on more mundane hardware.

I'm interested in determining the full range and diversity of PSFs -- as many lenses as possible.

I've tested dozens myself, largely old M42 lenses because I can afford them and modern Minolta/Sony alpha mount because that's the body I'm using for most tests. I'm most interested in the bokeh of the ones that are common or well known -- and that I don't have and can't afford. A diversity helps, and Pentax Forums seems to be an active community with very high diversity of lens use.

Zooms generally will require multiple focal length samples. I've been using the min and max focal lengths as the primary samples.

Contributions are still welcome, but with or without them the research continues. I expect to post some results no later than this Summer.

Heh , yeah, sorry - I wanted to do this, but I couldn't get to it before I forgot, and then I forgot... I do also have a technical constraint - distance... You mention 10m, but the most I can get in my house would be about 4m or so (just eyeballing it...). Is that distance enough to get you data (I'm not too inclined to go out at night to do this )? If so I will try to do some shooting for you.

Heh , yeah, sorry - I wanted to do this, but I couldn't get to it before I forgot, and then I forgot... I do also have a technical constraint - distance... You mention 10m, but the most I can get in my house would be about 4m or so (just eyeballing it...). Is that distance enough to get you data (I'm not too inclined to go out at night to do this )? If so I will try to do some shooting for you.

I also have been meaning to have a go at this but have so far failed to do so for the same reasons (the distance in particular). In order to see if it can be done effectively at shorter distances I decided to work out the bokeh diameter (circle of confusion) as a function of the object and focus distances and the lens focal length and F number. I have put the resulting equation in an Excel spreadsheet (attached in a zip file bellow) to make it easy to use.

From this I can conclude:
There are two ways of getting a large diameter bokeh so as to get a good image of it. These are:
a) The point light source must be distant and the focus must be set close (min focus distance), or
b) The point light source must be close and the focus set distant (infinity focus).

This is all as expected. Also as expected the diameter of the bokeh is inversly proportional to the F number.

The only other consideration is the light source. In order to get a measurement of the bokeh and not the light source the angular size of the light source must be as small as possible. For setup a) a 5mm LED at a distance of 10m as originally sugested would be a suitable point source but for setup b) the light source must be a lot smaller. A simple way of acheiving this would be to tape some aluminium foil over the front of the LED / torch and put a pinhole in it with a sewing needle. This should provide a small point source.

Now that I have worked out how to do it I will have to set it all up and take some pictures. Hopefully some results to follow soon...

Edit: the only contraint on how close the light source can be (asuming it is small) is that it must be more than 1 focal length away from the lens.

From this I can conclude:
There are two ways of getting a large diameter bokeh so as to get a good image of it. These are:
a) The point light source must be distant and the focus must be set close (min focus distance), or
b) The point light source must be close and the focus set distant (infinity focus).

It is worth noting that, in theory, (a) and (b) give different PSFs that are essentially "inverses" of each other. For example, bokeh chromatic aberration generally yields fringes of opposite colors before and after the focal point. Of course, real lens PSFs can have somewhat more difference....

Originally posted by MattGunn

This is all as expected. Also as expected the diameter of the bokeh is inversly proportional to the F number.

Smaller apertures yield correspondingly smaller PSFs until diffraction effects.... This also is true for geometric vignetting effects, so a circular PSF in the center of the field often will be "clipped" to a smaller shape off-axis of the lens.

Originally posted by MattGunn

The only other consideration is the light source. In order to get a measurement of the bokeh and not the light source the angular size of the light source must be as small as possible. For setup a) a 5mm LED at a distance of 10m as originally sugested would be a suitable point source but for setup b) the light source must be a lot smaller. A simple way of acheiving this would be to tape some aluminium foil over the front of the LED / torch and put a pinhole in it with a sewing needle. This should provide a small point source.

Yes, (b) is much harder to measure accurately. A pinhole will work, although there can be sensitivity to the size and shape of the pinhole. Even for (a), part of why a LED works well is that they don't have much texture or shape within that 5mm. A good test is repeatability; if rotating the camera+lens about the optical axis still gives the same structure (i.e., the image does not rotate WRT the sensor), you've got an appropriate light source (and alignment).

Except for macro photography, case (a) is not only easier to measure, but generally is assumed to be more important. In fact, typical multi-target autofocus systems give priority to focus on the closest object.

Your PSF size calculator looks about right, and "inverting" that formula is essentially how depth-from-defocus is done. This also makes it clear why, looking only at PSF diameter for depth-from-defocus, there is an ambiguity between distances before and after the focus distance.

It took a while to get round to starting and a while to sort out the photos afterwards but here is a first set of bokeh images. After a little trial I found that the bokeh varies quite a bit between wide open and closed by 1 to 2 stops as the aperture blades change the aperture shape. I continued and found that the diffraction effects become quite apparent at small apertures. For these reasons I have taken measurement of the bokeh over a range of apertures for each lens.
I didn’t have room for measurements at 10m but having taken onboard the comments about the reversal of the chromatic aberrations in the inverted bokeh images I made the measurements at 5m with the lenses focussed closer. Although this is half the recommended distance, the 5mm LED still has an angular diameter of only 1mrad and so in most cases I don’t think it will have too much effect. Please let me know if the closed aperture images are of no use to you as I won’t then bother with them in subsequent measurements. The images have all been uploaded to flickr and can be found here together with the information about the taking conditions: MattGunn2010's photosets on Flickr

Interesting thread, and I am considering also contributing, as I have an extensive set of lenses both old and new.

I do have, however, some questions and observations having done some benchmarking of lenses myself. Not as complicated as this task, but having the same variables as this.

First of all, there needs to be some simple guidelines set for exposure.

Specifically you need to ask everyone to keep the histogram centered because in the center the histogram is almost linear (in greyscale value) with Fstop or Exposure value.

Secondly, you need to have every one who takes images have the contrast setting of the camera calibrated. You do this by setting the camera to a middle F stop and then change the F stop and plot greyscale as a function of F-stop. I have found for example, just changing from maximum to minimum contrast (shooting jpegs of course) that the greyscale range per stop around the mean value of 128 can change by 20% i.e. in min contrast each stop is approximately greyscale change of 40 and at maximum contrast it is 50. People offering shots with different settings will provide you with errors due to settings.

third, in looking at your image from the 50mm SMC tak lens seems to show non uniform illumination top and bottom and therefore may not be a point source as far as your camera is concerned. I find Matt's shots moch more uniform top to bottom and side to side. So, we need a more controlled definition of the light source or setup to be able for you to provide your conclusions.

what is also interesting in some of matt's shots is the color shift of the fringing as you stop down, and the change in shape of the aperture where some lenses have pronounced points at certain apertures, some lenses have essentually round apertures, and others either hexagonal or optagonal as a function of blade count, as wellas the loss of symmetry of some aperatures as you stop down. This all will also have impacts on bokeh and the creation of artifacts like bright points creating starbursts. Can you give a little moe information on exactly how you will be evaluating bokeh?

First of all, there needs to be some simple guidelines set for exposure.

Specifically you need to ask everyone to keep the histogram centered because in the center the histogram is almost linear (in greyscale value) with Fstop or Exposure value.

Secondly, you need to have every one who takes images have the contrast setting of the camera calibrated. You do this by setting the camera to a middle F stop and then change the F stop and plot greyscale as a function of F-stop. I have found for example, just changing from maximum to minimum contrast (shooting jpegs of course) that the greyscale range per stop around the mean value of 128 can change by 20% i.e. in min contrast each stop is approximately greyscale change of 40 and at maximum contrast it is 50. People offering shots with different settings will provide you with errors due to settings.

Ideally, the exposures would be calibrated raw images and the histogram spike would be as close to the maximum as possible without clipping a channel. However, I'm not expecting perfection, just characterization good enough to drive a recognition and/or synthesis algorithm. The same goes for the contrast issues. Frankly, as soon as one uses JPEGs, it's all very approximate anyway....

Originally posted by Lowell Goudge

third, in looking at your image from the 50mm SMC tak lens seems to show non uniform illumination top and bottom and therefore may not be a point source as far as your camera is concerned. I find Matt's shots moch more uniform top to bottom and side to side. So, we need a more controlled definition of the light source or setup to be able for you to provide your conclusions.

Actually, I LOVE this little comparison because it is consistent with a guess I had made as to the cause. I knew it wasn't a light source defect because rotating the camera about the optical axis the pattern stays oriented with the sensor. In short, I believe the horizontal bias isn't a flaw in the light source, but a sensor reflection / mirror chamber masking artifact from my Sony A350 body -- different body, significantly different bokeh! The masking is probably the dominant effect, because Sony is quite aggressive about blocking stray light (i.e., from a full-frame lens). The 50mm f/1.4 Takumars seem to be exceptionally susceptible to this; for example, I don't see this artifact with my Opteka 85mm f/1.4.

Originally posted by Lowell Goudge

what is also interesting in some of matt's shots is the color shift of the fringing as you stop down, and the change in shape of the aperture where some lenses have pronounced points at certain apertures, some lenses have essentually round apertures, and others either hexagonal or optagonal as a function of blade count, as wellas the loss of symmetry of some aperatures as you stop down. This all will also have impacts on bokeh and the creation of artifacts like bright points creating starbursts. Can you give a little moe information on exactly how you will be evaluating bokeh?

I have been initially concentrating on wide open PSFs, however, the variations don't shock me. The little surprise for me is how evident diffraction effects are in some of the images... you don't see that much wide open.

As for exactly how I'm evaluating bokeh, it's pretty complicated, but here's how I got started.

I've been using CHDK to put various functions in cameras for research purposes for some time, and last year I supervised an undergrad senior project team at the University of Kentucky implementing depth map capture within an unmodified Canon PowerShot A620. The method used was simple depth-from-focus, capturing multiple images with different focus distances, determining which image was sharpest for each pixel location, and then creating a depth map image. It worked quite well -- where there was an edge or texture. Where there wasn't, it often hallucinated sharp edges at disturbingly incorrect distances. That's when I realized that the Gaussian blur model of defocus underlying all these algorithms was fundamentally and seriously wrong. So, last Summer I set out to develop a model of what lenses really do.

My initial models were mathematically perfect, noiseless, synthetic creations that I could use to test my matching algorithms. However, that doesn't tell me what real lenses do, nor what variations I can expect due to noise, JPEG processing, etc. That's what I've been testing lenses to determine... so far, I've measured PSFs for more than 3 dozen lenses on my Sony A350.... I've also tested quite a few compact digital cameras (most have small, but distinctive, PSFs).

My current best matching method involves a rather expensive Genetic Algorithm (GA), but it works quite well on perfect test images given enough time. The question is how well it can work with real lens PSFs, noise, etc. Using this approach, high quality depth-from-defocus should be possible from a single image... and then there are a bunch of other cool things one can do.

Here's a rather crude example of the kinds of other things one can do -- removal of obnoxious bokeh, a sample image pair from my "Technology Enabling Art" challenge series at dpreview:http://c.img-dpreview.com/0205120-01.jpg