Is there software that can highlight which parts of a photo are in focus after it’s taken?
Asked 1/11/2013
4 views
2 answers
0
I’m looking for a way to analyze an existing image and visually highlight the areas that appear sharp or in focus—something like focus peaking, but applied in post-processing. Is there software or a common method for doing this reliably?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
13y ago
2 Answers
16
The simple recipe is to convolve with a Laplacian of Gaussian kernel (3x3, with 8 in the middle surrounded by -1 and take the abs(result)) . After this you get some artifacts if it is a jpeg image, and out of focus borders that have a high intensity difference will also "ping". The result you can threshold to detect the strongest edges and remove teh artifacts. Let the threshold be generous, letting a few fake specks through. Then median filter the image and you get a cleaner result.
For the example below I used Image View Plus More: 1. original 2. abs(LoG convolution ) 3. threshold 4. median filter
There are more advanced approaches using Gabor filters in fourier domain, and using the gaussian pyramid approach. Halcon (which is very expensive) has some examples with these methods.

Originally by user11455. Source · Licensed CC BY-SA 4.0
user11455
13y ago
0
Generated from our catalog & community — verify before relying on it.
Yes—approximately. There isn’t a perfect “post-process focus peaking” for every image, but you can estimate sharp areas by detecting strong high-frequency detail.
Common approaches mentioned:
- Use a high-pass filter (available in Photoshop and similar editors). Sharp edges will stand out more than soft areas.
- Use edge-detection methods such as a Laplacian-of-Gaussian filter, then take the absolute result, threshold it, and optionally clean it up with a median filter.
In practice, this highlights areas with strong fine detail, which often correspond to in-focus regions. However, it’s not foolproof:
- High-contrast blurred edges can still be flagged.
- JPEG artifacts can create false positives.
- Texture and contrast affect the result, so “sharp-looking” output is only an estimate of focus, not a definitive depth-of-field map.
So yes, image editors and image-processing tools can do a useful approximation, but the result should be interpreted as sharpness/edge strength rather than a precise focus indicator.
Recommended products
UniqueBot
AI13y ago
Your Answer
Related Questions
Can existing out-of-focus areas be detected and selectively intensified in post-processing?
Can photo software automatically detect or rate how in-focus an image is?
How can I quickly visualize highlights, midtones, and shadows in an image?
How can I merge bracketed exposures into one HDR image in Photoshop?
How can I keep several areas in focus while other parts stay blurred?