combines differently focused images imagei of the same scene to obtain a single well-focused image.

Details and Options

  • ImageFocusCombine is also known as focus stacking or Z-stacking. It is typically used for combining multiple images of the same scene taken at different focus distances and creates an image with a higher depth of field (DOF).
  • ImageFocusCombine assumes all imagei are aligned.
  • ImageFocusCombine takes a PerformanceGoal option. Possible settings include:
  • "Quality"optimize for quality of final results
    "Speed"optimize for speed of getting results


open allclose all

Basic Examples  (1)

Combine images of a scene with two different regions in focus:

Scope  (1)

Combine a stack of images with different focal planes:

Options  (2)

PerformanceGoal  (2)

Use PerformanceGoal->"Quality" to emphasize quality of the result:

Use PerformanceGoal->"Speed" to emphasize speed of computation:

Applications  (1)

Inverse tilt-shift effect on three images with three different regions in focus:

Compare with the starting image:

Properties & Relations  (1)

Areas in focus are defined by the location of high frequencies in the image:

Combine the image with a high-frequency, rich, random image:

Combine the image with a lowpass-filtered, random image:

Possible Issues  (2)

ImageFocusCombine does not correct for misalignment:

Use ImageAlign to align the images before combining them:

In some cases the misalignment is too large and cannot be corrected automatically:

This usually results in a ghosting effect:

Manually remove the most misaligned images from the stack to mitigate the ghosting effect:

Wolfram Research (2015), ImageFocusCombine, Wolfram Language function,


Wolfram Research (2015), ImageFocusCombine, Wolfram Language function,


@misc{reference.wolfram_2021_imagefocuscombine, author="Wolfram Research", title="{ImageFocusCombine}", year="2015", howpublished="\url{}", note=[Accessed: 13-June-2021 ]}


@online{reference.wolfram_2021_imagefocuscombine, organization={Wolfram Research}, title={ImageFocusCombine}, year={2015}, url={}, note=[Accessed: 13-June-2021 ]}


Wolfram Language. 2015. "ImageFocusCombine." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2015). ImageFocusCombine. Wolfram Language & System Documentation Center. Retrieved from