Digital Photography 201: Stacking Images

© Brooke Clarke 2011

Background
Focus Stacking 1 - Adobe Stack
Focus Stacking 2a - Adobe Stack & Stitch
Focus Stacking 2b - Adobe Stack
Focus Stacking 3 - Non Adobe
High Dynamic Range Stacking
    Adobe online CS4 Tutorial on HDR
    Example
    Nikon Active-D Lighting
Panorama, Stitching, Cylindrical & Spherical Image Stacking
Object Removal Stacking
Higher Resolution Stacking
Blur Removal
Books & DVDs
Related
Links

Background

With film images could be stacked by making multiple exposures either in the camera or in the darkroom, but the amount of control was very limited.  With a digital image and Photoshop or other post processing software much more can be done.

For learning about Adobe products there are video tutorials at: http://tv.adobe.com/

Focus Stacking (Wiki)

One area where this applies is in close up photography where the Depth Of Field is much smaller than the subject so in a single exposure only a small fraction of the subject will be in focus.  By taking a number of exposures in manual focus mode then combining them to get a single image that has a much greater depth of field.

The book Digital Macro Photography (2006) has no mention of focus stacking, but does cover other aspects of Photoshop.

In Photoshop CS4 (starting with no images loaded):
File \ Scripts \ Load Images Into Stack (do not use: File \ Automate \ Photomerge)
Click on Browse and select the files to stack (holding CTRL and using the mouse allows selecting non adjacent files)
Leave both of these unchecked: Attempt to Automatically Align Source Images & Create Smart Object After Loading Layers
Click OK

In Layers, select all or in the top menu Select choose Select All Layers

Edit \ Autoblend Layers Check Stack Images and optionally select Seamless Tones and Colors

First in Focus
                      Stacking Series
Last in Focus
                      Stacking Series
Seamless Tones and Colors Not Selected
Stack of 6 Images
                      to Improve depth of focus


Seamless Tones and Colors Selected
Stack of 6
                      Images to Improve depth of focus

Focus Stacking 2a

Merge Depth of Field with Photoshop CS4 - The first part did not work to well (I had the same fuzzy edge problem), but the second method does work well.

Open multiple images in Photoshop CS4.  Then open a new file.  Drag from the layers pane of each image into the new file.  You can close all the source files now.
Select all the layers in the new file and: Edit Auto-Align Layers.
Then Edit Auto-Blend Layers using the Stack Mode with a check in the box for Blend seamless Tones & Colors.

Note that a three dimensional subject will require a number of overlapping photos (tiles) that will be combined at the end of the process using just the Edit \ Auto-Align Layers.  (If you use Edit Auto-Blend the background will be different for each tile.)  Prior to that step each tile is made up of a number of frames that have different focus settings (all other settings the same) and these are combined using first Edit Auto-Align then Edit Auto-Blend Layers.  This results in a tile that is more in focus than any single exposure can be.

Deer Tile 1
3 frames

Deer TIle 4
4 frames
Deer Tile 3
2 frames

Deer TIle 5
3 frames

Deer Tile 6
3 frames
Deer TIle 7
4 frames
Big Deer All Tiles
The perspective looks wrong.  Camera on tripod and pan and tilt to cover subject.
Would be better if the camera was translated for coverage and moved in/out for focus.
The final image is 6921 x 10382 vs theory of 6000 x 9000 for a 20" x 30" print @ 300 PPI
Single Frame
Deer Nose
                      single frame image




This opens up the idea of rather than stitching multiple
tiles to get the needed resolution.  You could do focus
stacking where each image would be up sized to the
final required resolution (9000x6000 for a 30 x20 print),
then focus stacked.  The idea is that the actual resolution
would be improved.


Focus Stacking 2b

When working with NEF (RAW) images,
----- In Adobe Camera Raw make adjustemets to all stack images at the same time ----
1-11) Select all the images in Windows file explorer (hold CTRL and click on each image file to be used in the stack) then OPEN
1-2) In Adobe Camera Raw use the SELECT ALL button at the upper left so you can work on them as a group
1-3) make any adjustments - I typically work down from the top starting with the exposure
   (push to the right so specular highlights are blown out, push up the blacks and maybe add some fill light.)
1-4) Image \ Mode select 8bits/Channel (I have my camera set to 14 bits/Channel, so Adobe uses 16 bits/Channel (much larger file size)
1-5) SAVE AS and select .tif
1-6) OPEN IMAGE (will take you to Photoshop (CS4 or higher)
-------in Photoshop build the stack Note: each image will be a .tif file-----
2-1) Create a new image (File \ New ) which will hold the stack  You can name it something appropriate for the combined image
2-1) Use Window \ Arrange and cascade, tile or whatever works for you so you see and access all the files for the stack.
2-3) Resize all the images so that you can select the full image easily
2-4) Open the Layers Panel
2-5) Click on the image frame (to start with the lowest numbered one, then in order)
2-6) Surround the image with the select tool (dotted rectangle) and <CTRL><C> to copy it to the clip board
2-7) Click on the new image frame
2-8) Click on it's layers panel (by clicking on the new image frame it's layers panel should be the active panel)
2-9) <CTRL><P> (to paste image into the stack
2-10) Click on the source image (selected in step (2-5) and delete it by clicking on the "X" in it's title bar
      This is important because it frees up computer RAM
2-11) If all the source images have been used goto step (3-1)
2-12) select the next image
2-13) Goto step (2-6)
------Combine the stack into a single image ----
3-1)  If you have plenty of RAM goto step (20)
19) Reduce the size of the stack images IMAGE \ Size can change the width in the pixels box.

One of the 7 images used
One
                      of the 7 images used in a focus stack

Focus stack of 7
                      images



Focus Stacking 3 - Non Adobe

StackShot - a motorized rail that advances the camera and trigers an exposure
Helicon Focus stacking software
An Introduction to Focus Stacking — Extended Depth of Field Digital Photography by Rik Littlefield
Wiki -
An Introduction to Focus Stacking - changing the lens focus not as good as moving camera
Open-source Photographic Motion Control technology.

CombineZ

There are third party programs for focus stacking.  A free program is CombineZ() As of 12 Oct 2011 it's CombineZP by Alan Hadley, prior versions were CombineZ5 and Combine ZM.  The name is derived from Combining images that are stacked in the Z plane, i.e. X & Y are the left right planes and Z is the up and down plane.  The author of the program uses it for taking photos of things like insects using a microscope.

Zerene Stacker

Prices range from $40 to $290.

Helicon Focus

Price range $30 to $350.
Supports Trinamic PANdrive PD-110-42 & StackShot

Automated Camera Movement

Create An Automated Macro Rail For Image Stacking -

StackShot - moves camera, triggers shutter, keeps doing it.  Shutter release cables for common cameras.  200mm extended slide.
Computer connection with USB.
Pat App 12/927,166 Motor controlled macro rail for close-up focus-stacking photography

Trinamic PANdrive PD-110-42 available from Semiconductor Store (California)

High Dynamic Range (HDR) Stacking

The idea is to take a series of shots covering under, normal and over exposure and then stack them to achieve a wider dynamic range of brightness.

Important Notice

Instead of using HDR methods, it's much better to use RAW files from the camera.  On the Nikon D300s the RAW image contains 12 or 14 bits per color compared to the 8 bits per color that you get on all .jpg images.  That's a 6 bit (same as 6 f stops) increase in dynamic range!

For example when taking product photographs for my web pages it's common that you can not see into the shadows, but when Adobe Camera Raw (ACR) is used to process the RAW image moving the fill light slider allows seeing detail in the shadows.  No need to take multiple exposures to cover the dynamic range.


Adobe online CS4 Tutorial on HDR

 Take photos for HDR images
  • Secure the camera to a tripod.

  • Take enough photos to cover the full dynamic range of the scene. You can try taking at least five to seven photos, but you might need to take more exposures depending on the dynamic range of the scene. The minimum number of photos should be three.

  • Vary the shutter speed to create different exposures. Changing the aperture changes the depth of field in each exposure and can produce lower-quality results. Changing the ISO or aperture may also cause noise or vignetting in the image.

  • In general, don’t use your camera’s auto-bracket feature, because the exposure changes are usually too small.

  • The exposure differences between the photos should be one or two EV (exposure value) steps apart (equivalent to about one or two f‑stops apart).

  • Don’t vary the lighting; for instance, don’t use a flash in one exposure but not the next.

  • Make sure that nothing is moving in the scene. Exposure Merge works only with differently exposed images of the identical scene.

- Merge images to HDR -
  1. Do one of the following:
    • (Photoshop) Choose File > Automate > Merge To HDR.

    • (Bridge) Select the images you want to use and choose Tools > Photoshop > Merge To HDR. Skip to step 3.

  2. In the Merge To HDR dialog box, click Browse, browse to select the images, and click Open.

    To remove an item, select it in the Merge To HDR dialog box and click Remove.

    Note: If you want to add a folder of images or images that are open in Photoshop, choose Folder or Open Files from the Use menu.
  3. (Optional) Select the Attempt To Automatically Align Source Images option if you held the camera in your hands when you photographed the multiple images.
  4. Click OK.

    A second Merge To HDR dialog box displays thumbnails of the images being used in the merged result, a preview of the merged result, a Bit Depth menu, and a slider for setting the white point preview.

  5. If necessary, do one of the following to set the view options for the merged result preview:
    • Click the Minus or Plus buttons below the preview image to zoom out or zoom in.

    • Choose a view percentage or mode from the pop‑up menu below the preview image.

  6. Choose a bit depth for the merged image from the Bit Depth menu.

    Be sure to choose 32 Bits/Channel if you want the merged image to store the entire dynamic range data of the HDR image. 8‑bits and (non-floating point) 16‑bpc images files cannot store the entire range of luminance values in an HDR image.

  7. Move the slider below the histogram to preview the merged image.

    Moving the slider adjusts the image preview only. All the HDR image data remains intact in the merged image file. If you’re saving the merged image as 32‑bpc, the preview adjustment is stored in the HDR image file and applied whenever the file is opened in Photoshop. The preview adjustment is always accessible and adjustable by choosing View > 32‑Bit Preview Options.

  8. Click OK to create the merged image.

    If you chose to save the merged image as an 8‑bits or 16‑bpc image, the HDR Conversion dialog box opens. Make the exposure and contrast corrections to produce an image with the dynamic range (tonal range) you want. For more information, see Convert from 32 bits to 8 or 16 bpc.

Convert from 32 bits to 8 or 16 bpc

HDR images contain luminance levels that far exceed the luminance data that can be stored in 8‑ or 16‑bpc image files. You can make exposure and contrast corrections when converting a 32‑bpc HDR image to 8 or 16 bpc to produce an image with the dynamic range (tonal range) you want.

  1. Open a 32‑bpc image and choose Image > Mode > 16 Bits/Channel or 8 Bits/Channel.
  2. In the HDR Conversion dialog box, choose a method for adjusting the brightness and contrast in the image:
    Exposure and Gamma
    Lets you manually adjust the brightness and contrast of the HDR image.
    Highlight Compression
    Compresses the highlight values in the HDR image so they fall within the luminance values range of the 8‑ or 16‑bpc image file. No further adjustments are necessary; this method is automatic. Click OK to convert the 32‑bpc image.
    Equalize Histogram
    Compresses the dynamic range of the HDR image while trying to preserve some contrast. No further adjustments are necessary; this method is automatic. Click OK to convert the 32‑bpc image.
    Local Adaptation
    Adjusts the tonality in the HDR image by calculating the amount of correction necessary for local brightness regions throughout the image.
  3. (Optional) Click the arrow to display the toning curve and histogram. The histogram shows the luminance values in the original HDR image. The red tick marks along the horizontal axis are in 1 EV (approximately 1 f‑stop) increments. The toning curve is active only for the Local Adaptation method.
  4. Do any of the following:
    • If you chose Exposure and Gamma, move the Exposure slider to adjust the gain and move the Gamma slider to adjust the contrast.

    • If you chose Local Adaptation, move the Radius slider to specify the size of the local brightness regions. Move the Threshold slider to specify how far apart two pixels’ tonal values must be before they’re no longer part of the same brightness region. You can also use the Toning Curve and Histogram to make adjustments.
      Note: The Toning Curve and Histogram usually lets you make limited changes from point to point and attempts to equalize your changes across the points. If you select the Corner option after inserting a point on the curve, the limit is removed and no equalization is performed when you insert and move a second point. You’ll notice that the curve becomes angular at a point with the Corner option applied.

      Toning Curve and Histogram adjustment using the Corner option

      A.
      Inserting a point and selecting the Corner option.
      B.
      Adjusting new point makes the curve angular at the point where the Corner option is used.
  5. (Optional) To save your 32‑bit toning options as a file, click Save. Type a name for the file in the Save dialog box and click Save.

    You can reuse the saved 32‑bit toning option file. Click Load to convert another 32‑bpc image to an 8‑ or 16‑bpc image.

  6. Click OK to convert the 32‑bpc image.

Example

The camera was pointed in the direction of the Sun, except it was level.  The shooting position was choosen so that the lens was in total shade because of the trees.

 Five exposures (M mode) were made in 1 stop steps, only the -2, 0 and +2 are shown below.
The nominal exposure was: 1/100, f/5 ISO500 105 mm tripod Nikon Active-D Lighting turned off.
The focus is not as sharp as it could be.  Need to colapse tripod, use Mirror Up and check focus by making a trial exposure and using the "+" to magnify the image on the LCD.  Also using bracketing with Mirror Up should minimize the change for movement.

High Dynamic Range
                    -2EV Forest Tree
High Dynamic
                      Range meter exposure Forest Tree
High Dynamic Range
                    +2EV Forest Tree
1/400, f/5 ISO500 105 mm tripod
Nikon Active-D Lighting turned off.
1/100, f/5 ISO500 105 mm tripod
Nikon Active-D Lighting turned off.
1/25, f/5 ISO500 105 mm tripod
Nikon Active-D Lighting turned off.

16 bit HDR image
                    using Exposure & Gamma reduction from 32 bit
                    image

16 bit HDR image using Exposure & Gamma
reduction from 32 bit image


Nikon Active-D Lighting

In the Shooting Menu about 3/4 of the way down is Active-D Lighting.  (Note: searching the Nikon manual for HDR will not work because they have their own name for it.)  The possible settings are:  Off, Low, Normal, High, Extra High, Auto.  The example below was at Extra High.

So far I prefer the image using the internal Active-D Lighting over the stacked HDR method.  That may be because I haven't perfected the method.
High Dynamic Range HDR
              in Nikon D300s Active-D Lighting set to Extra High
High Dynamic Range HDR in Nikon D300s Active-D Lighting set to Extra High
The focus is better than the stacked version above.  Maybe allowing Photoshop CS4 to align the images rather than trust the tripod would improve the focus in the stacked HDR image?

Panorama, Stitching, Cylindrical & Spherical Image Stacking

Many cell phone cameras and digital cameras have internal stitching to make panoramic images but the images are not of the same quality as a modern digital SLR camera and these typically do not have internal stitching.  The end product is an image that is very wide.  Most photo processors do not offer a print format that has the extreme aspect ratio that these images require for printing.  One thing that can be done, instead of having a print made with a lot of white space, is to make the image size half height on a standard landscape print size.   For example you can place two panorama images each 4" h x 12" w on a single 8x12 print.  The photo processor probably will cut them apart for no extra charge.

Apple has what they call QuickTime VR (Virtual Reality or QTVR)(Wiki) where a number of photos, typically taken using a leveled tripod and an angle adapter are then combined into a single image that can be viewed on a computer and you can pan and tilt to see much more than a static frame.  Google Street View uses something like this.  The images can be combined either using a cylindrical or spherical model.

File \ Automatic \ Photomerge
Choose images to stitch together
Check the dot next to Reposition
OK

Stiched image Photoshop
                    CS4 Source was 6 portrait images each a .tif file aobut 35 MB.
Combined file 162 MB 6000 pixels wide x 2296 pixels high.

The tripod was not leves so you can see a little vertical offset in each tile.

This was the first experiment in looking for stars in the daytime.
Notice that the top of the frame is darker, as it should be
because as the elevation angle goes up (and toward the North star) the sky gets darker
The Zenith is one of the places that can be aimed at without a calibrated mount
The Zenith is one of the places that can
                      be aimed at without a calibrated mount
A 300 mm FL lens at f/2.8 has an objective diameter of 300/2.8 = 107 mm or 4.21" dia.

From the Visual Magnitude Equation 2 at:
http://www.prc68.com/I/Mag.shtml
Mag = 5 * Log10( D ) + 8.8 = 5 * 0.625 + 8.8 = 11.9
but this is for night time viewing.  Who knows for daytime star viewing?

Panoramic Hardware

GigaPan EPIC Pro - holds a DSLR camera and lens that can weigh up to 10 pounds and can take an almost spherical image (can not shoot straight up or down and limited by lens length) by means of stitching.

Object Removal Stacking

Object Extraction

In Photoshop CS4 you need to download the ExtractionPlus Plug-In.  It comes as a zip file.  When the zip file is run it put the extracted files in a folder on my desktop named "Adobe CS4" but I didn't know that so it took an hour of expirmenting to find it.  Once there work your way down through all the folders to the ExtractPlus.8BF filter.  Another way would be to run the zip extraction program to get the .exe.   Run the .exe then search your computer for ExtractPlus.8BF.  Move it into the \Pluug-ins\Filters folder for your installation of photoshop CS4 (32 bit in my case WIN XP).

In order to get Photoshop CS4 to show Extract in the Filters drop down box it was necessary to restart WIN XP.  Now it's working.

Before you can use the history brush you must first enable history (which is a huge memory hog) under Edit \ Preferences \ General.
The history brush has an icon like the regular bursh plus is has a circular back arrow superimposed.

Object Removal

Based on this video.  First the undesired objects are extracted from the image and replaced by black.

Photoshop Tutorial :: Using the Extract Filter

In the Layers \ Smart Objects \ Stacking menu choose Maximum (since black is what we want to eliminate.
Subject with
                        blocking Image1
Subject with
                        blocking Image2

Blocking
                        Image1 Extraceted & Replaced with Black
Blocking
                        Image2 Extraceted & Replaced with Black
Subject with
                        both blocking images removed by using Smart
                        Objects

Higher Resolution Stacking

Using Photoshop to increase the number of pixels is "hollow" expansion since no new informationis added.  PhotoAcute has a method of combining a number what appers to be identical images in such a way that they can double the image resolution.  Some of these programs work on a single image and others use stacking, so I'm putting them all on this stacking web page.

Resolution Enhancement (Wiki: Super-resolution)

BlowUp

Requires Photoshop CS3 or later (Elements 7 or later)
Works better than the photoshop bicubic methodworks on single image
$ 200

Fixer Labs

Three resolution enhancement products works on single image
Home ($ 30) - low cost for camera phones
SLR ($120) - 68 MP size limit, good for 23" by 33" @ 300DPI
XL ($200) -  2 GP size limit, good for 20"x23" @ 1000 DPI

Photo Acute

Works by stacking images for specific camera + lens combinations.  Best with RAW files.
Recomended that a small motion be made between shots on a tripod.
They claim a doubling of resolution in each axis and so the minimum number of images is 4, but 5 or 6 images makes for a better result.
Includes HDR and noise reduction so using ISO in the 400 to 800 range is recomended.
When the camera and lens are one of the supported combinations, lens distortion can be corrected.
Removing moving objects is also an option.
Also does focus stacking.
Photographic Multishot Techniques (see below) covers using this software
Standard/Lite/Mobile ($30) - Compact and prosumer cameras & cell phones
Pro/Studio ($150) - DSLR + "

Perfect Size 7 (Genuine Fractals)

Requires Photoshop CS4 or CS5.  Works on a single image.  Contains sharpening that can be applied just before submitting to print. 

Professional Edition ($200) - Supports resizing CMYK images, Gallery Wrap feature - add extended margins, Integrates with Lightroom, Integrates with Aperture
Standard Edition ($100) -

Blur Removal

The idea is to analyze an image (or part of an image) and determine how the camera was moved during the exposure then correct the image for that motion.  This is in development.  Here's a video of the Sneak Preview at the Oct 16 2011 Adobe MAX conference.

Books & DVDs

Photographic Multishot Techniques: High Dynamic Range, Super-Resolution, Extended Depth of Field, Stitching [Paperback] By: Juergen Gulbins, Rainer Gulbins

Related

Digital Photography 101 The Basics
Digital Photography 202: Close-Up, Macro & Micro
Photography - about my experiences
Nikon - cameras and accessories
Ukiah - a number of photos

Links



Brooke's PRC68, Products for Sale, End 2 Party Government
[an error occurred while processing this directive] page created 9 Aug. 2011.