PhotographyRecreating bokeh (just an idea)

Bokeh is that nice off-focus effect that good lenses can give you on portraits or photos of details, helping centering your attention on your subject and not on the background of the photo.

Unfortunately, “nice” bokeh is well-tied to “nice” (==expensive) lenses. And sometime simply you just have a photo shot with too much depth of field (maybe because there was too much light, or the photographer, for example my 6-years old daughter, just know to point and shot). So I thought… it’s possible to reproduce it on a photo after the fact?

The poor man solution is easy: select your foreground in GIMP or Photoshop or whatever you use to edit your photo, invert the selection, blur. But this does not look like bokeh at all. The problem is that with real bokeh, distant point of light are transformed in big disks, and nearer one (although off focus) on smaller ones. So I though… well, let’s try to play a bit.

So I prepared three “bokeh masks” that would represent how a point of light can be transformed at high, medium and low distances. See the example at the left.

Now the trick is to select one photo and to prepare a mask for it. Paint black the foreground, which will be left as-is, and in different shade of gray the other parts of the photo, from near (dark gray) to far (light gray) to very far (white). See the photo and the mask below.

(click on the photo to see the original photo, full size). now I have written a little program that apply the “blur” or, technically speaking, convolute the correct bokeh image on the photo.Here is the result:

(click for full size)

The program is written in python, it’s dog slow, it can be done better, the mask has been done with the electronic equivalent of a hammer, etc. etc. But this post is just to show the idea. In principle, a general program would interpolate among the bokeh images, to accept more than three levels of “distance”… but think the experiment you can do with it! Would you try an octagonal bokeh effect? Or a doughnut one?

Doughnut bokeh:

And this is one made with an hexagonal aperture pattern:

It’s a very subtle difference, but it’s there — I especially like the hexagonal one.

If you like I can share the program under GPLv3 license, for free inclusion in free software. For other kind of licenses, contact me 🙂

BTW, it seems that I effectively reinvented the wheel. See here…

Have a nice day!


Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>