Luminous Landscape Forum

Raw & Post Processing, Printing => Digital Image Processing => Topic started by: Guillermo Luijk on July 28, 2011, 01:21:13 pm

Title: How 'Focus Peaking' works
Post by: Guillermo Luijk on July 28, 2011, 01:21:13 pm
Focus Peaking (http://www.youtube.com/watch?v=HGPF375-2rA) is a real time facility of current Sony mirrorless NEX cameras that shows the user the areas in focus in the scene currently being displayed. To illustrate how 'Focus Peaking' works I tried to reproduce the process in Photoshop. It is quite simple, so I see no reason why any mirrorless camera could not implement it.

To detect in-focus areas in an image is just a matter of detecting microcontrast (i.e. fine detail), something these cameras already need to do in their AF system.

Starting from any real time capture:

(http://img40.imageshack.us/img40/4028/escena.jpg)


The simplest way to detect microcontrast is through a high pass filter (HPF). In the areas in focus, the detail will trigger a threshold set in the HPF, while out of focus areas wont's do so for being totally blurred in terms of high spatial frequencies.

I desaturated the previous image (this makes things simpler, but it's in fact the way to work on undemosaiced data) and applied a simple HPF inside Photoshop (Filter -> Others -> Custom):

(http://img94.imageshack.us/img94/38/kernel.gif)


By applying an adequate boolean threshold over the result of this filtering, we can detect the borders in focused areas, and this information can be overlayed on the original image as NEX cameras do. Out of focus areas were very far from reaching the HPF output threshold:

(http://www.guillermoluijk.com/misc/escena1.gif)


Only the borders of in-focus areas are marked since we are strictly detecting microcontrast (a plain colour area won't display any microcontrast, no matter if it is in focus or not). But perhaps for the photographer it is more adequate to see areas in focus rather than borders or isolated pixels, like Capture One does for instance. These areas can be displayed over the image without needing to animate. So we could have a real time view of the scene of this kind:

(http://img856.imageshack.us/img856/228/escena2.gif)

(http://img200.imageshack.us/img200/6527/escena2s.jpg)


We determined that in the neighbourhood of the pixels in focus, there should exist some area in focus of a reasonable radius of influence. This over simplified algorithm can be improved a lot, but the concept remains clear.

Another example here:

(http://img691.imageshack.us/img691/4618/florgq.jpg)


Would result in the following focus display:

(http://www.guillermoluijk.com/misc/flor.gif)


Adjustable parameters for the Focus Peaking would be needed to control sensitivity (according to aperture used, sharpness of the lens,...):


Regards
Title: Re: How 'Focus Peaking' works
Post by: deejjjaaaa on July 28, 2011, 02:15:18 pm
> NEX

I think that it is used in video cams for years already, right ? so it is not not like Panasonic for example did not implement it before.
Title: Re: How 'Focus Peaking' works
Post by: Rhossydd on July 29, 2011, 01:28:34 am
I think that it is used in video cams for years already, right ?
Correct. It's been in use for the best part of forty years on broadcast cameras, possible more.

Coloured peaking is horrible and not worth bothering with. Well set up white is easiest to use.
The latest Sony HD broadcast cameras like the HDC1500 and viewfinders like the HD75Vf have something like a dozen different parameters to configure to control peaking performance.
Title: Re: How 'Focus Peaking' works
Post by: Eric Myrvaagnes on July 29, 2011, 10:32:32 am
Beautiful demo, Guillermo. Thanks for posting it.

Eric
Title: Re: How 'Focus Peaking' works
Post by: Mike Sellers on July 31, 2011, 09:37:08 am
Very interesting! Would it be possible to set this proceedure up as an action in Photoshop?
Mike
Title: Re: How 'Focus Peaking' works
Post by: Guillermo Luijk on July 31, 2011, 09:54:14 am
Very interesting! Would it be possible to set this proceedure up as an action in Photoshop?
I guess it is (I do not know much about PS actions though). However I don't think this would be of much interest. I used Photoshop just for illustration purposes, but the point of these techniques is to be applied while focusing on the camera, implemented in their firmware.

Another example, now with false positive detection: the filter detected microcontrast in the window in the background although it was in an out of focus area. This was because the strong difference in luminance window glass vs window frame.

(http://www.guillermoluijk.com/misc/fpcerny.gif)

(http://www.guillermoluijk.com/misc/fpcerny.jpg)


I used the RAW blue channel (no demosaicing).

Title: Re: How 'Focus Peaking' works
Post by: Guillermo Luijk on July 31, 2011, 02:17:00 pm
And another example, specially propicious to work fine (high contrast text and drawings):

Lines in edges:

(http://www.guillermoluijk.com/misc/libro1.gif)


Or with zones:

(http://www.guillermoluijk.com/misc/libro2.gif)

which style would you prefer on your camera?


Regards
Title: Re: How 'Focus Peaking' works
Post by: hjulenissen on August 01, 2011, 09:26:56 am
Would perhaps be neat to use in a micro-adjustement tool?

"Take an image of this print, and see immidiately where the focus lies. Add/detract some amount from the MA in the camera, and repeat..."

-h
Title: Re: How 'Focus Peaking' works
Post by: NikoJorj on August 01, 2011, 10:09:35 am
Brilliant as usual!

For me, I'd like the edges display a bit better than the zone one - eg in intricate views, like when the AF hunts for the bird in the middle of a tree, the zone display may not be as useful.
Title: Re: How 'Focus Peaking' works
Post by: Mike Sellers on August 04, 2011, 08:10:43 am
I was thinking that this would be a way to imitate the focus function in Capture one that allows one to see where the sharp areas are on a captured image. I take numerous shots of each scene and vary the way I focus each one so I found it illustrative to use this function in C1 to see which image has the best focus.
Title: Re: How 'Focus Peaking' works
Post by: erick.boileau on January 12, 2013, 03:08:34 am
Very interesting  ... and nearly no answers

many thanks
Title: Re: How 'Focus Peaking' works
Post by: Fine_Art on January 12, 2013, 05:20:55 pm
Thanks for providing this good info.
Title: Re: How 'Focus Peaking' works
Post by: Remo Nonaz on January 14, 2013, 04:52:56 pm
There is an interesting post at http://www.petapixel.com/2012/10/25/olympus-om-d-em-5s-art-filter-works-nicely-as-a-focus-peaking-feature/ (http://www.petapixel.com/2012/10/25/olympus-om-d-em-5s-art-filter-works-nicely-as-a-focus-peaking-feature/) explaining how to use the 'Fine Art' mode of an Olympus m43 camera to create a focus peeking effect. It seems to work in the video.

I have a GH2. I'll have to try the various art modes and see if any of them can do the same trick. If I could get it to work, it would be very useful when using manual focus lenses.
Title: Re: How 'Focus Peaking' works
Post by: auctionman on January 20, 2013, 09:20:42 am
Thank you for such a great demo!
Title: Re: How 'Focus Peaking' works
Post by: DanOksnevadPhotography on October 08, 2013, 11:34:59 am
Wow, this is an awesome technique! I've used the High Pass Filter for softening skin tones & to add contrast to portraits, but never for "Focus Peaking"...  I'm going to try it on some shots from last weekend's wedding. Thanks for sharing!
Title: Re: How 'Focus Peaking' works
Post by: Glenn NK on October 08, 2013, 12:48:41 pm
Guillermo:

Excellent presentation (and as usual, your posts are always interesting, educational and useful).

Now I'm wondering; if this has been used for years in video, why haven't we had it in our DSLR's?

The outline version would be very useful in macro work, particularly if the colour could be changed to suit the object.

White might be the best option for many subjects, but not of much use for a white flower for example (or a bride in white!).

Glenn
Title: Re: How 'Focus Peaking' works
Post by: cottagehunter on October 08, 2013, 10:54:35 pm
The sony a99 allows you to do focus peaking in one of three colur choices. Red, Yellow and White

Pierre
Title: Re: How 'Focus Peaking' works
Post by: eliedinur on October 10, 2013, 02:49:48 am
Magic Lantern provides focus peaking for Canon cameras plus a lot of other goodies and most excitingly an adaption inspired by Guillermo's "Zero Noise" in a single shot with alternating rows ISO amplified at different gains.
Title: Re: How 'Focus Peaking' works
Post by: Dr Tone on October 11, 2013, 08:59:37 am
Now I'm wondering; if this has been used for years in video, why haven't we had it in our DSLR's?

It's not something that is achievable through an optical view finder for starters.  Sony has had it in their DSLT cameras for a while.

I use it all the time with my A99.
Title: Re: How 'Focus Peaking' works
Post by: Glenn NK on October 12, 2013, 02:42:09 pm
It's not something that is achievable through an optical view finder for starters.  Sony has had it in their DSLT cameras for a while.

I use it all the time with my A99.

I should have been more specific - why not available in LV?
Title: Re: How 'Focus Peaking' works
Post by: SunnyUK on October 29, 2013, 05:59:26 am
Very interesting. Thank you.
Title: Re: How 'Focus Peaking' works
Post by: MichaelEzra on October 29, 2013, 09:35:59 am
RawTherapee also features Focus Mask functionality, the algorithm there is a bit different - it is based on analysis of standard deviation of image details on two different scales.