simulated depth of field?

  • Graham Toal

    Graham Toal - 2007-04-16

    (I just now posted this as a feature request - that was before I found out you had a chat forum.  Sorry, I'm new to Sourceforge, signed up today)

    Hello. I've just finished reading your description of enblend
    ( and it occurred to me when I
    was reading about the pyramid and the detection/separation of spatial
    frequency information, that this is a process that could easily be adapted
    to taking two (or more) images of a single scene (not a panorama but almost
    fully overlapping) - usually an extreme macro closeup - which were taken
    with different focus depths, and extracting the in-focus information from
    each and blending them so that the composite image had the focused parts
    from each of the inputs, i.e. a simulated increase in depth of field.

    Now, there is seldom anything new in computing, so having had this idea I
    did a search to see if anyone had done it before or had written code to do
    this function. What I found first was a paper on increasing depth of
    fields using wavelets
    (, so I still had hope
    that this was a new algorithm :-), but my hopes for having found a new
    algorithm were dashed when I saw this page:

    *HOWEVER* I can't find anyone who has actually implemented this algorithm
    in free software (although I did find one commercial implementation:\)

    I wish I had the expertise to add this feature to your program but my
    programming expertise lies elsewhere (I'm not innumerate but I tend to be
    weak on anything that involves higher maths; I remember starting to
    struggle a bit at university 30 years ago when we got to FFTs... that's
    about my limit), so...

    I was hoping you or one of your collaborators might be interested in adding
    this feature to your program (or creating a spin-off program with 99% of
    the code base in common but the panorama interface removed for

    My interest in this comes from being a nature photographer and frequently
    not being able to focus on an entire butterfly, beetle, or even flower when
    using a good macro lens which unfortunately has an almost paper-flat depth
    of focus. I frequently will have the front wing of a butterfly in focus in
    one frame and the rear wing in focus in the next, but am unable to focus on
    both simultaneously unless I'm very lucky and catch a butterfly basking in
    the sun with its wings flat :-)

    I'll be more than happy to supply images that would make good tests.

    One small complication *may* be that the camera moves a tiny amount forward
    or backwards between frames, making perhaps a 1% difference in scale. From
    reading the autosift documentation, it sounds like the SIFT algorithm
    should compensate for that. However until we try to align some images I
    don't even know if it is an issue. Hopefully my hand is steady enough that
    it doesn't happen.

    Best regards

    Graham Toal <>

    • Graham Toal

      Graham Toal - 2007-04-16

      PS The same code, probably unchanged, could also work for increasing the detail from a range of exposures (under, correct, and over) - in effect, a simulated fill-in flash.

      • Graham Toal

        Graham Toal - 2007-04-16

        > The same code, probably unchanged, could also work for increasing the detail from a range of exposures (under, correct, and over) - in effect, a simulated fill-in flash.

        Like this:

        Also I forgot to mention improving resolution by sub-pixel
        image registration.

        So... three things which are closely related,

        * Resolution (sub-pixel registration)
        * Focus/depth of field enhancement
        * Contrast/dynamic range enhancement

        All of which are closely related to enhance and hugin/autosift.

        (Actually there's another closely related area I haven't mentioned, and that is 3D image registration and perhaps depth map extraction from focus info.  Save that for another year :-) )

        There seem to be more tools available for supperresolution and contrast enhancement than there are for depth of field enhancement.

        Although it would be nice to have a toolset which did all of the above, I don't want to be greedy, so my enhancement request is only for the original suggestion, which was enhanced depth of field - which I'm hoping will 'fall out in the wash' due to the pyramid data structure that you've already computed, and so with luck it won't be a major hack to add...

        PS. Still Googling now I have a few new keywords to try... found this,
        it seems to do the right function but not very well... maybe because he's using an FFT to find the focused areas? -
        His 'problems' page highlights issues that I don't think
        we would see using software like enhance:

    • Graham Toal

      Graham Toal - 2007-04-17

      After about three hours of Googling :-( I finally found the original web page that got me interested in this subject - this guy uses a commercial package called "syncroscopy" to photograph beetles.  Some of the images in his set are quite superb:


      (Tool: )

      By the way, here's another page on the subject:

      Looks like PanoTools has a hacked version of the code (uses the red channel only, for focusing - again, just short of ideal, still haven't found a completely free and technically excellent solution)



Log in to post a comment.