Focus peaking is a relatively new feature that is currently making its way into the newer digital cameras that are coming out. Peta Pixel reported on this feature appearing on the latest Sony cameras here:
One of the interesting technologies Sony introduced into its line of NEX mirrorless cameras last year (starting with the NEX-C3) was “focus peaking”, a feature from the video recording world that highlights in-focus areas of an image to aid in manual focusing. You know those colorful pixels that image editing programs use to indicate blown out or underexposed areas of photos? It’s like that, except for focus. What’s awesome is that you can adjust things like focus, focal length, and aperture, and then see the depth of field adjust on your screen in real time.
You can see a video below of how this works:
Basically the areas of the image that are in focus are being highlighted by the camera so that you can easily see what will be in focus when you take the shot. It enables you to fine tune the focus precisely the way you want.
It’s a very nice feature to have on the camera. But this got me thinking. When editing pictures in Photoshop, I often find myself wanting to edit only the parts of a picture that are in focus, or sometimes just the parts of a picture that are out of focus. For example, when applying noise reduction to images, I usually want to do this mostly for the out of focus areas (bokeh) of an image, and leave the detail inside the in focus areas intact. Wouldn’t it be awesome if we had a selection feature in Adobe Photoshop or Lightroom where we could easily select only the areas of an image that are in focus? The way this would work is exactly like the “Color Range” selection process in Photoshop, but only instead of a range of colors, it would select a range of focus. It would start by selecting the areas that are sharply in focus, and you could then increase the range/radius to include more of the picture in your selection extending more to the out of focus areas.
To my knowledge there’s no such feature in Photoshop or in any plugins that I know of. So I decided to try and see if I could use the functionality that is currently in Photoshop to build a selection in an image of only the areas that are in focus. It turns out that it’s possible to do this, although it’s not quite perfect, and you can even create an action to automate the process. It should be relatively easy for Adobe to include such a focus selection option in Photoshop, but until they do, we’ll have to use a different way.
The way I’ve tried to do this is by trying to detect the edges and details inside an image that are sharply in focus mostly by using a High Pass filter. Once you have the edges that are in focus selected, you can expand the selection around those edges and get a rough, sometimes even pretty accurate, selection of the areas in an image that are in focus. This method is by no means perfect, but it can help if you want to quickly and automatically select the areas of an image that are in focus. You can then refine the mask/selection afterwards if needed.
Some issues with this method:
Obviously trying to create this functionality in an action is limiting and won’t always give the best results. Only the Photoshop guys at Adobe or a plugin developer has the kind of low level access and flexibility to be able to make this better.
Below are some examples to show that it does work:
In the examples below I used sample images from the Canon EOS 1DX from Canon Inc’s website.

In focus areas are highlighted in bright red (after Focus Peaking Lines Only action). On the left you can see the selection you end up with when using the Focus Peaking action.
You can download actions that automate the steps shown in the below tutorial by clicking on this link. There’s a .atn file in the zip file which you can open in Adobe Photoshop. There are 3 actions inside this file:
PLEASE NOTE: Run these actions on the background layer after opening the image in Photoshop. These actions are optimized for images that are between 10-21 megapixels in size. For smaller images you may need to adjust certain settings as explained in the tutorial below. These actions only work for 8-Bits/Channel and 16-Bits/Channel images (the Color Range selection option is not available for 32-Bits/Channel images in Photoshop).
I’ve created a step by step tutorial below to show how to simulate focus peaking in Photoshop. You end up with a mask containing a rough selection of the areas in an image that are in focus. I’ll be using the image below in this tutorial. You can download a high resolution version here.
I will be posting updates here when there are bug fixes and/or improvements to the actions. If you run into any issues let me know. If you have suggestions for improvements also let me know. :) The latest update can be downloaded here.
Great action idea. It worked on one of my images but for most it doesn’t. I get the message: “Could not complete the command because the selected area is empty.”
It gets to the fill part but there does not appear to be anything on the Layer 1 that it creates????
How about “find edges” in filters?
At least for the lines.
Some filter actions are not available in 16 (or 32) bit mode… That may be why some actions are not allowed.
Hi Karel:
Looks great. Capture One has included this capability in their last couple of versions and I always wondered why Adobe never picked it up for LR and CS.
Does your action(s) run under Mac CS?
Awesome tool! Thanks for putting in the time and effort!
Cheers!
Thanks for reading “Photoshop Aktuell”. I’ve described such a method of sharpness detection via high pass filtering about 5 years ago in this magazine. In this issue I did not only describe focus detection with this filter, I also described a method for focus expanding – before Adobe implemented a corresponding function in Photoshop. And I described a lot of very interesting things you also can do with the high pass filter, e.g.. exact denoising, moiré removal, precise sharpening a.s.o. What you write here maybe interesting – but it is not new. Really new is, what you can read in the newest issue of “Photoshop Aktuell”, published in about 2 weeks: There I describe a really new method, how you can extract any unknown corrections from a low-res reference file of a digital image and apply these corrections to an uncorrected hi-res file of the same image, so the hi-res file looks exactly like the reference file – only in high resolution.
Hi Karl
Seemed to run into a problem – “The Command “Make” in not currently available”. What does that mean please?