This question may be somewhat uninformed, as I am certainly no expert on the notions involved, so please bear with me :)

In the context of manipulating synthetic bokeh in post-processing,

settling for using gaussian blur as a substitute for actual bokeh (I know that they are distinct things, see e.g. "What's the difference between Bokeh and Gaussian Blur?", but for the matter on topic we'll forget about this),

can't we just use, e.g., contrast detection, and maybe other methods, to learn where bokeh already exists in a given image, and then intensify this bokeh? (Instead of having the photographer/user define where to artificially put a guassian blur.)

I can very well imagine a technique like this to work. You could, sequentially:

  1. Use contrast detection, and, for example, if bokeh circles exist, simply measure their diameter, to create a "heat map" of bokeh in the image.
  2. Then you could put a gaussian blur (or other kind of artificial bokeh) over the image, weighted by the heat map of step 1.
  3. Now you have an image where the bokeh is not created from scratch, but simply intensified from already existing bokeh.

(And if worried that in-focus areas bay be blurred, you could also, say, put gaussian blur where the heat map values are above e.g. .2 (in a scale of 0 to 1), and possibly even apply "the opposite thing", say local contrast, below .2)

  • \$\begingroup\$ How do you tell what was actually an edge and what is in focus and not an edge though? CDAF only works because it can tell when contrast reaches the peak. \$\endgroup\$
    – AJ Henderson
    Commented Jul 3, 2014 at 18:45
  • \$\begingroup\$ (Well I have no definite technical answer, as I don't know these things in-depth, but I can very well imagine post can deduce quite good what is in focus and what not. Maybe "contrast detection" is toot technical a word for what I imagine is possible. Say, for example, you use the fact that bokeh "smears" things together, so you measure how similar neighbouring patches of pixels are—not neccessarily looking for contrast edges..) \$\endgroup\$ Commented Jul 4, 2014 at 12:27
  • \$\begingroup\$ In focus vs out of focus is the same thing though, you can find the highest contrast points and you know that those are in-focus edges, but if things are out of focus, it is far, far more difficult to tell if they were edges or not. As Matt Grum mentions, there are some more complicated ways to try and guess, but they aren't super reliable because it involves very complex image processing and/or assuming that some things are edges that might not be. \$\endgroup\$
    – AJ Henderson
    Commented Jul 4, 2014 at 16:41

2 Answers 2


This is known in the field of image processing as "depth from defocus". What you are suggesting is possible to a degree, the results will never be the same as you'd get (especially if you use Gaussian blur rather than lens blur!) but it will simulate a certain amount of

There are various techniques to achieve depth from defocus, it's a bit more involved than estimating contrast, however I believe the latest version of Photoshop CC has a bokeh masking feature. I don't know if you get different levels or if it is just an in-focus/out-of-focus (black and white) mask.


Alien Skin had a Bokeh plugin for Photoshop that handled the subtle fogging of defocussed hi-lights - photoshop CS6/CC now has what looks like the same function and system in Field Blur - the key is to have some scattered highlight points in your image


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.