Many users are requesting focus assist tools [1] [2] [3] for their Magic Lantern-enabled DSLRs.

/* scroll down for video */

Magic Lantern FAQ[edit | edit source]

According to Six Ways at forums, the zoom and focus peaking focus assist features "work with or without a chipped adapter," as " Neither of these depend on the lens or the camera AF-confirm." This is significant, as it allows the use of manual lenses such as Nikon or Olympus, to be used with a focus assist feature typically found only on expensive monitors.

Zoom during Recording[edit | edit source]

AJ posted some very impressive demos which enable zoom during recording:

See 2.0.4 AJ and this discussion.

Focus peaking[edit | edit source]

Input data: LiveView buffer: VRAM/550D, 2.0.4_5D2_VRAM_overlay

There are VRAM segments with 720p YUV data when idle, which increase to 1080p when recording. AJ found a bunch of them: ASM Zedbra.

5D2 has edge detection implemented, but it seems it's too slow for real use. Users say it's not very good [4]. Anyone has a link with screenshots or discussion about this?

A tentative of estimating the "amount" of focus is here: [5].

There is an implementation of edge detection in C which claims to be very fast [6] (didn't test it).

Focus with Image Morphology[edit | edit source]

My empirical observations show that morphological operation (dilate/erode/open/close) [7] [8] [9] [10] may help with focus assist. However, they are computationally intensive.

In simple words:

  • Dilate: expands white (light) areas of image
  • Erode: expands the black (dark) areas

Basic idea: focused areas have details which are lost by open/close operation. Out of focus areas don't have those details.

Thresholding edge image[edit | edit source]

  • fixed: you risk to display either a big, red mess in a sharp scene, or nothing at all if you have a softer lens.
  • adaptive: what about percentile? e.g. display the sharpest 1% pixels

thumb|300px|left|Testing percentile threshold (1%) with edge detection

Experiment: is morphological method more accurate than edge detection? if yes, is it worth optimizing it?[edit | edit source]

(probably not)

  • Method 1: simple edge detection, based on horizontal and vertical differences between adjacent pixels:
# octave3.2, y is YUV luma
dyh = y(1:end-1,1:end-1) - y(1:end-1,2:end);
dyv = y(1:end-1,1:end-1) - y(2:end,1:end-1);
e = abs(dyv)+abs(dyh);
  • Method 2: diff between original frame and morpho-closed one.
  • Method 3: diff between original frame and morpho-opened one.
  • Method 4: add images from 2 and 3.
Community content is available under CC-BY-SA unless otherwise noted.