ImageFocusCombine[{image1,image2,…}]
combines differently focused images imagei of the same scene to obtain a single well-focused image.
ImageFocusCombine
ImageFocusCombine[{image1,image2,…}]
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
Examples
open all close allBasic Examples (1)
Scope (1)
Options (2)
PerformanceGoal (2)
Use PerformanceGoal->"Quality" to emphasize quality of the result:
ImageFocusCombine[{[image], [image]}, PerformanceGoal -> "Quality"]//AbsoluteTimingUse PerformanceGoal->"Speed" to emphasize speed of computation:
ImageFocusCombine[{[image], [image]}, PerformanceGoal -> "Speed"]//AbsoluteTimingApplications (1)
Properties & Relations (1)
Areas in focus are defined by the location of high frequencies in the image:
image = [image];Combine the image with a high-frequency, rich, random image:
random = RandomImage[1, ImageDimensions@image];ImageFocusCombine[{image, random}]Combine the image with a lowpass-filtered, random image:
ImageFocusCombine[{image, GaussianFilter[random, 4]}]Possible Issues (2)
ImageFocusCombine does not correct for misalignment:
images = {[image], [image], [image], [image]};ImageFocusCombine[images]Use ImageAlign to align the images before combining them:
alignedimages = ImageAlign[images];ImageFocusCombine[ImagePad[#, -7]& /@ alignedimages]In some cases the misalignment is too large and cannot be corrected automatically:
images = RemoveAlphaChannel /@ ImageAlign[{[image], [image], [image]}];This usually results in a ghosting effect:
ImageFocusCombine[images]ImageDifference@@@{images[[{1, 2}]], images[[{1, 3}]]}Manually remove the most misaligned images from the stack to mitigate the ghosting effect:
ImageFocusCombine[images[[{1, 2}]]]History
Text
Wolfram Research (2015), ImageFocusCombine, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageFocusCombine.html.
CMS
Wolfram Language. 2015. "ImageFocusCombine." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ImageFocusCombine.html.
APA
Wolfram Language. (2015). ImageFocusCombine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageFocusCombine.html
BibTeX
@misc{reference.wolfram_2026_imagefocuscombine, author="Wolfram Research", title="{ImageFocusCombine}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ImageFocusCombine.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_imagefocuscombine, organization={Wolfram Research}, title={ImageFocusCombine}, year={2015}, url={https://reference.wolfram.com/language/ref/ImageFocusCombine.html}, note=[Accessed: 12-June-2026]}