Focus Blending in PTGui

808 views
Skip to first unread message

Eric

unread,
Mar 6, 2009, 11:32:59 PM3/6/09
to PTGui Support
Dear PTGui,

Are there any plans in integrate Focus Blending into PTGui?


To the rest of the PTGui users,

I am trying to focus blend really large multi-row panoramas with
objects in close and far proximity within each frame at different
distances and am trying to figure out the most effective way to: 1)
shoot it, 2) stitch it.

Shooting, you have to consider speed (changing light, etc.)
practicality for complexity (eg. manually focusing to 5 different
distances within each frame would be not too precise or practical)

Possible methods of shooting:
1) Shoot the entire panorama at one focus distance, change focus,
reshoot entire pano, change focus, reshoot, repeat.

2) My normal workflow would be to shoot the entire panorama with the
best overall focus distance, and then go back and shoot any areas that
require different focus distances.

3) Shoot the entire panorama once, each frame focusing several times
and taking shots. Very slow, requires looking through view finder and
using DOF-preview to determine that you've captured everything in that
frame in focus.


Possible methods for stitching:
1) Focus blend each individual frame. Stitch focused blended images.
This could prove inaccurate for shooting methods 1+2. I also hear that
this may cause stitching problems because each focus blended image has
slightly different DOF and create parralaxing. Julian Kalmar talks
about this here:
http://luminous-landscape.com/forum/index.php?showtopic=32223&st=0&p=262482&#entry262482

2) Render a pano for each focus distance used in method 1 and then
focus blend the panos (I've tried tufuse, enfuse, and combineZP and it
seems that they all crash because the pano file is too big for them,
especially when you have 5 * 600mb files)


I think there may be some possibilities in using PTgui and replacing
Enblend with Enfuse or Tufuse for blending.

I've read a couple of threads that discuss doing this, such as the
garlic, but they seem rather inefficient, particularly using photoshop
etc. I want to avoid having to manually select stacks and process
them.



Ideas?

PTGui Support

unread,
Mar 7, 2009, 1:59:43 AM3/7/09
to pt...@googlegroups.com
Hi Eric,

Maybe in the future, but for now I'm concentrating on panoramic stitching..

Joost

luca vascon

unread,
Mar 7, 2009, 4:51:42 AM3/7/09
to pt...@googlegroups.com
I got similar problems in the past...
FIRST contrast blending
SECOND exposure blending
THIRD stitching.
Plan everything in advance, shoot focusing only where it is needed,
but ALL FULL ROWS and in different folders right in camera, and
then...
the focusing fused ones ARE with a different focal lenght...
Multiresolution panoramas... are you familiar?!

2009/3/7 PTGui Support <sup...@ptgui.com>:

Erik Krause

unread,
Mar 7, 2009, 5:19:50 AM3/7/09
to pt...@googlegroups.com
Eric wrote:

> Possible methods of shooting:
> 1) Shoot the entire panorama at one focus distance, change focus,
> reshoot entire pano, change focus, reshoot, repeat.

Not good. Most likely the single panoramas won't stitch such that you
can overlay them. You won't be able to use a template like for exposure
stacks since parallax and magnification changes. If you stitch each
panorama separately you most likely won't get a good alignment (which is
crucial for focus stacking) since small errors add up from image to image.

> 2) My normal workflow would be to shoot the entire panorama with the
> best overall focus distance, and then go back and shoot any areas that
> require different focus distances.

Not good either. See above.

> 3) Shoot the entire panorama once, each frame focusing several times
> and taking shots. Very slow, requires looking through view finder and
> using DOF-preview to determine that you've captured everything in that
> frame in focus.

First you should determine the nearest and furthest focus distance you
need. Then you decide for the steps you need for the whole thing and
shoot a focus stack for all positions.

This way you have the same number of images for every stack and can
select simply by number and choose a master focus plane to anchor all of
them to. You can align them in PTGui allowing individual FoV for any but
the anchor focus plane and use enfuse (instead of enblend) to fuse them.
Another benefit is that you can use the focus stack with most alignable
images as a template for the other ones.

For efficient use of enfuse for focus stacks see the new manual at
http://wiki.panotools.org/Enfuse_reference_manual

The last step is to stitch the panorama from the resulting images of
each focus stack.

--
Erik Krause
http://www.erik-krause.de

Mick Crane

unread,
Mar 7, 2009, 6:20:39 AM3/7/09
to pt...@googlegroups.com, pt...@googlegroups.com
I mark nearest and farthest distance on a piece of tape on the lens
and then mark maybe 7 inbetweens. Do the focus stack then move the
camera. It can flow along quite smoothly Especially if you have
someone prepared to fire the shutter.
I am thinking about a foot switch when on my own.
Regards
Mick

Juan Villa

unread,
Mar 7, 2009, 3:33:05 PM3/7/09
to pt...@googlegroups.com

> You can align them in PTGui allowing individual FoV for any but
> the anchor focus plane and use enfuse (instead of enblend) to fuse
> them.


Hi Erik:
Do you mean that all images in a focus stack have different FoV? even
though they are shot at the same focal length?
Juan

Erik Krause

unread,
Mar 7, 2009, 4:31:51 PM3/7/09
to pt...@googlegroups.com
Juan Villa wrote:

> Do you mean that all images in a focus stack have different FoV? even
> though they are shot at the same focal length?

What actually changes is the magnification. If you align a focus stack,
the rear end of the DoF range of one shot must be aligned with the front
end of the other. If conventionally focused (using the focus ring of the
lens) each image has a different magnification, hence the FoV must be
changed to align them.

Even in macro-photography, where you use a slide to focus the
magnification at the rear and front end of the DoF range is different
for conventional lenses.

Field of view and focal length are not that directly related as it seems
(and many books tell). Other factors (especially the entrance pupil
location) influence them. The extreme example would be a telecentric
lens, where the entrance pupil is at infinity behind the lens (!) The
field of view (or better angle of view) for such lenses is 0.0°, that
is: the actual field of view (the visible area) is always as large as
the entrance pupil, no matter what distance. Those lenses are best for
macrophoto focus stacks, since the magnification doesn't change
throughout the DoF range and there is no parallax between adjacent images.

For in-depth reading see
http://www.janrik.net/PanoPostings/NoParallaxPoint/TheoryOfTheNoParallaxPoint.pdf
(same link short: http://tinyurl.com/d29lu )
More on telecentric lenses and their use for focus stacks (with a really
nice example): http://www.photomacrography.net/forum/viewtopic.php?t=1032
Search

luca vascon

unread,
Mar 7, 2009, 6:00:55 PM3/7/09
to pt...@googlegroups.com
mouth switch is good...
:-)
friends love it coz I stop talking...

2009/3/7 Mick Crane <mick....@gmail.com>:

luca vascon

unread,
Mar 7, 2009, 6:19:23 PM3/7/09
to pt...@googlegroups.com
yesssssssss....
Substantially, the\FOV is changing when you focus the lens.
Usually the closer you focus the narrower the fov, so if you shoot the
whole room (Fenice theatre in Venice, i.e.) focusing at 50m with a
100m f2.8, and when you get closer you refocus, as you must do...
Each focusing stack will have the usable FOV of the closest focusing image.
This will give you the cloe on how to plan the whole thing.
In ptgui there are some nice tricks to optimize the images in GROUPS.
Other trick you can use is to zoom out the lens, or change it, for
closer subjects. This icreases the depth of field and also allows
using real resolution only for the detailed roof or paintings, not for
close chairs and floor.
I do not use zooms, so I change lens, I move from the 60 or the 100 to
a more flexible 18 or 28mm.
Take care that color rendition may be different!!! I'm using Zeiss
contax primes and the difference between them is not so big! I chose
the ones that perform in a similar way and however make a shot of a
white plastic disposable coffee cup to calibrate the white point...

2009/3/7 Erik Krause <erik....@gmx.de>:

Eric

unread,
Mar 9, 2009, 12:44:17 PM3/9/09
to PTGui Support
Erik, thank you for your advise. Yes, Option #3, (shooting the pano
once, performing multiple focuses at each frame) sounds like the only
option for success.

Do you have to shoot a focus stack for each position, or can you mix
focuse fused images with non-focus fused? Luca mentioned "the focusing
fused ones ARE with a different focal lenght... " is this a problem to
mix different focal lengths when stitching?

Would someone be kind enough to explain to me the following tasks:

1) "select simply by number and choose a master focus plane to anchor
all of
them to"

2) "align them in PTGui allowing individual FoV for any but
the anchor focus plane"

3) "In ptgui there are some nice tricks to optimize the images in
GROUPS."


I know how to select a single stack of images (files) manually and
then use Hugin's align_image_stack.exe and then run enfuse to create
the focus blend. It would take a lot of time to manually select each
group of images and then run the commands.
I would like to know how to automate the process using PTGui, which I
believe is the answer to the points above. It seems to me that you
could load all of the images into PTGui, align them all at once, and
then render a fused stack for each image automatically.


eric

Erik Krause

unread,
Mar 9, 2009, 4:21:32 PM3/9/09
to pt...@googlegroups.com
Eric wrote:

> Do you have to shoot a focus stack for each position, or can you mix
> focuse fused images with non-focus fused? Luca mentioned "the
> focusing fused ones ARE with a different focal lenght... " is this a
> problem to mix different focal lengths when stitching?

More or less. Basically you can mix images from large and small focus
stacks and even single shots. Once the images are fused PTGui doesn't
know anything about the stacking - they are just normal images. However,
the Filed of View might be different. This is no big problem, since
PTGui can deal with individual lens parameters for single images.

There is another disadvantages of not using the same number of images
for each stack: You will need to select the images manually. If you have
f.e. 5 images each stack you can simply chose images 1-5 for stack one,
6-10 for stack two and so on.

But of course there is little point shooting images with only blurred
content. Some cameras record the focus distance in exif data. In this
case you can use f.e. exiftool to determine focus stacks.

I do this in a similar way with exposure info in my
enfuse_auto_droplet.bat: It enfuses images as long as their lightvalue
increases and starts a new bracketing stack if it decreased (assuming
that exposure stacks where shot with increasing exposure of course). Get
the batch file from http://www.erik-krause.de/enfuse_droplets.zip

> 1) "select simply by number and choose a master focus plane to anchor
> all of them to"

Doing as described above you get a number of focus stacks. You should
decide for a master focus plane, lets say image 3 in each stack in above
example. This image's FoV will not be changed. Images 1, 2, 4 and 5 will
be changed.

> 2) "align them in PTGui allowing individual FoV for any but the
> anchor focus plane"

If you shot the images without moving the camera only FoV should change
between the images and if you could precisely repeat focus positions you
can use one stack as a template for each other which you can use without
optimizing. If you need to align Yaw, Roll and Pitch as well or if you
couldn't precisely repeat the focus position, this won't be possible and
you will have to optimize each stack.

> 3) "In ptgui there are some nice tricks to optimize the images in
> GROUPS."

I think Luca means the advanced Optimizer tab where you can select and
deselect groups of images for optimization easily.

Eric

unread,
Mar 12, 2009, 5:43:09 PM3/12/09
to PTGui Support
Thanks Erik!

I have modified your enfuse_align droplet to Focus Blend images using
Tufuse instead of Enblend. I found that Tufuse does a more accurate
job blending.

Now I can fully automate the entire creation of all the stacks. I even
made a version that takes into consideration the focus order that was
shot. You always have to have the nearest distance (most narrow FOV)
as the master focus plane or it will not work. I found when shooting
it was most efficient to shoot a stack from near to far and the next
stack from far to near, repeat. So, I modified the script to process
every second set backwards so the master focus plane is always the
nearest focal distance.

The only problem, is it seems to take FOREVER. After 1.5 hours, I have
only produced 11 stacks, from 6 focus distances each. I still have 100
more stacks to go. I guess that put me at 10 hours. My computer can
fully render a 4Gigapixel image in under an hour. What's the deal?

I think I could speed things up if I could save the alignment data for
the stacks, so that it doesn't have to be generated each time. On
occassion, some stacks aren't turning out, must be a problem with the
control points that were generated. Is there any way for me to create
the alignment data from an ideal set, and then save and reuse for all
the other stacks?



Erik Krause

unread,
Mar 12, 2009, 6:05:31 PM3/12/09
to pt...@googlegroups.com
On Thursday, March 12, 2009 at 14:43, Eric wrote:

> I think I could speed things up if I could save the alignment data for
> the stacks, so that it doesn't have to be generated each time. On
> occassion, some stacks aren't turning out, must be a problem with the
> control points that were generated. Is there any way for me to create
> the alignment data from an ideal set, and then save and reuse for all
> the other stacks?

If you use PTGui to align the stacks you can use any stack as a
template for the others. I suspect this is even batchable if you have
the latest pro version, but I never tried.

align_image_stack can output a .pto file (a derivative from
PTStitcher script file syntax), which can be used with nona (the
hugin command line stitcher): http://wiki.panotools.org/Nona
http://wiki.panotools.org/Align_image_stack

This would require some shell script programming especially since any
second focus stack is in reverse order. But since you managed this
already for align_image_stack it should be little problem.

More info on PTStitcher scripts and command line usage on
http://wiki.panotools.org/PTStitcher


best regards
Erik Krause
http://www.erik-krause.de

Reply all
Reply to author
Forward
0 new messages