This is the first in a series of posts about constructing and using a bokeh simulator. If you want to easily navigate to the other parts, at the bottom of this post (below the comments) you’ll find pingback links to each of them.
I’ve been reading a lot of controversy about lens bokeh, and it occurred to me that it wouldn’t be too hard to build a program that simulated the effect of a lens with arbitrary bokeh on a real scene captured in focus. The inputs to the code would be the sharp image, a idealized or real out-of-focus (OOF) blur circle, and directions for scaling the blur circle. Eventually, the blur circle could be scaled with a depth map image, but initially, it would be sufficient to render the entire output image with a uniform blur circle.
The idea would be to allow people to see how real or imagined lenses rendered a wide variety of OOF backgrounds, so that they could select lenses appropriate for their chosen subject matter.
I limbered up my typing fingers today and wrote come Matlab code to implement a first cut at the project. I’ll show you some images, then I’ll discuss the limitations of what I’ve done.
Here’s what I mean by 2-sigma and 1-sigma falloff in the above. In the former case, the outermost edge of the apodizing element is one sigma out from the mean of the distribution in its center. With a 2-sigma falloff, the edge of the apodizer is two sigma away from the mean. 1-sigma falloff is subtly different from the perfect blur circle which was simulated for the images with the word “disk” in their captions. I have corrected for the different exposures required by the simulated apodized lenses.
What are the limitations?
- I can’t simulate accurately blur circles so small that they are close to the diffraction and aberration blurring. The above simulation assumes that all the blurring performed on the putative sharp image is from defocusing.
- I’m assuming that the nature of the OOF blur circle changes only by scaling as the lens is defocused. That appears to be materially the case in my testing of real lenses.
- The simulation is only accurate if the original image is sharp.
Where to do from here?
- I’m going to do some work with real lens OOF point spread functions.
- I’m going to try some other sharp images.
- If anyone has sharp images they’d like me to use, please get in touch with me.
- Eventually, I may get around to depth mapping. It’ll be crude at first.
I am open to suggestions.