ImageAlign[ref,image]
returns a version of image that is aligned with the reference image ref.
ImageAlign[ref,{image1,…,imagen}]
gives the result of aligning each of the imagei with the reference image ref.
ImageAlign[{image1,…,imagen}]
uses image1 as the reference image.
ImageAlign
ImageAlign[ref,image]
returns a version of image that is aligned with the reference image ref.
ImageAlign[ref,{image1,…,imagen}]
gives the result of aligning each of the imagei with the reference image ref.
ImageAlign[{image1,…,imagen}]
uses image1 as the reference image.
Details and Options
- ImageAlign[image1,image2] finds a transformation of image2 that registers it with image1 and returns the result of applying this transformation to image2.
- ImageAlign works with arbitrary 2D and 3D images.
- Resulting images have the same dimensions as the reference image.
- Use FindGeometricTransform to compute the geometric transformation used for alignments.
- The following options can be specified:
-
Background Automatic background value Method Automatic alignment method to use TransformationClass Automatic geometrical relation between images - Possible settings for the Method option are:
-
Automatic automatically choose a suitable method "Keypoints" use corresponding keypoints {"Keypoints",method} use an ImageCorrespondingPoints method "MeanSquareGradientDescent" minimize the mean square distance of corresponding pixels "Fourier" Fourier-based registration "FourierBlurInvariant" blur invariant Fourier-based registration - With the default setting TransformationClass->Automatic, ImageAlign attempts to find the simplest possible transformation.
- Possible transformations in order of increasing complexity are:
-
"Translation" translation only "Rigid" translation and rotation "Similarity" translation, rotation, and scaling "Affine" linear transformation and translation "Perspective" linear fractional transformation
Examples
open all close allBasic Examples (2)
Scope (2)
Align a list of three images to a reference image:
ImageAlign[[image], {[image], [image], [image]}, IconizedObject[«...»]]Align a list of three images, using the first image as the reference:
ImageAlign[{[image], [image], [image]}, IconizedObject[«...»]]Length[%]Options (11)
Background (1)
Method (5)
By default, ImageAlign uses an automatic combination of methods and initializations:
ImageAlign[[image], [image]]The "Keypoints" method works well with natural 2D photos:
ref = [image];image = [image];ImageAlign[ref, image, Method -> "Keypoints"]ImageAlign[ref, image, Method -> {"Keypoints", "KAZE"}]Use all keypoints detected by multiple methods:
ImageAlign[ref, image, Method -> {"Keypoints", {"ORB", "KAZE"}}]The "MeanSquareGradientDescent" method uses dense distances between images:
ImageAlign[[image], [image], Method -> "MeanSquareGradientDescent", TransformationClass -> "Affine"]This method typically needs a large initial overlap between images:
ImageAlign[[image], ImagePad[[image], 30], Method -> "MeanSquareGradientDescent", TransformationClass -> "Affine"]The "Fourier" method can align images even with a small overlap:
{i1, i2} = {[image], [image]};res = ImageAlign[i1, i2, Method -> "Fourier"]HighlightImage[ImageCompose[i1, {res, .5}], {FaceForm[], EdgeForm[Thick], AlphaChannel[res]}]Use the "FourierBlurInvariant" method in the presence of noise and motion blur:
{i1, i2} = {[image], [image]};ImageAlign[i1, i2, Method -> "FourierBlurInvariant"]ImageCompose[i1, {%, .5}]TransformationClass (5)
Restrict the transformation to only translation:
ImageAlign[[image], [image], TransformationClass -> "Translation"]"Rigid" transformation allows for rotations in addition to translations:
ImageAlign[[image], [image], TransformationClass -> "Rigid"]"Similarity" transforms allow for translation, rotation, and scaling:
ImageAlign[[image], [image], TransformationClass -> "Similarity"]Allow any affine transformation:
ImageAlign[[image], [image], TransformationClass -> "Affine"]ImageAlign[[image], [image], TransformationClass -> "Perspective"]Applications (4)
Align an image with its mirror image:
ImageAlign[[image], [image]]i1 = [image];i2 = [image];aligned = ImageAlign[i1, i2];
ImageCompose[aligned, {i1, .5}]Align two different images of the same object:
ImageAlign[[image], [image]]Align images before performing focus stacking:
images = {[image], [image], [image], [image]};aligned = ImageAlign[images]ImageFocusCombine[aligned]Compare with the stacking without alignment:
ImageFocusCombine[images]Properties & Relations (2)
For aligning images using a specific set of corresponding points, use FindGeometricTransform:
{i1, i2} = {[image], [image]};pts1 = {{47.5, 151.5}, {149.5, 151.5}, {150.5, 50.5}, {47.5, 52.5}};
pts2 = {{64.5, 185.5}, {164.5, 173.5}, {184.5, 49.5}, {68.5, 54.5}};{e, t} = FindGeometricTransform[pts1, pts2]Transform the image with ImagePerspectiveTransformation:
ImagePerspectiveTransformation[i2, t, DataRange -> Full, Padding -> 0]Use FindGeometricTransform to find the geometric transformation that aligns images:
i1 = [image];i2 = [image];{e, tr} = FindGeometricTransform[i1, i2]Stitch images together by transforming one and composing on top of the other one:
{w, h} = ImageDimensions[i2];
tmp = ImagePerspectiveTransformation[i2, tr, DataRange -> Full, PlotRange -> {{0, First@tr[{w, 0}]}, {0, h}}];
ImageCompose[tmp, {i1, .7}, Round@({w, h} / 2)]See Also
ImageStitch ImageCorrespondingPoints FindGeometricTransform ImageKeypoints ImageTransformation ImageCorrelate
Function Repository: ImageAlignFaces
History
Introduced in 2010 (8.0) | Updated in 2014 (10.0) ▪ 2015 (10.2) ▪ 2016 (11.0) ▪ 2017 (11.1) ▪ 2021 (13.0)
Text
Wolfram Research (2010), ImageAlign, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageAlign.html (updated 2021).
CMS
Wolfram Language. 2010. "ImageAlign." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImageAlign.html.
APA
Wolfram Language. (2010). ImageAlign. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageAlign.html
BibTeX
@misc{reference.wolfram_2026_imagealign, author="Wolfram Research", title="{ImageAlign}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImageAlign.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_imagealign, organization={Wolfram Research}, title={ImageAlign}, year={2021}, url={https://reference.wolfram.com/language/ref/ImageAlign.html}, note=[Accessed: 13-June-2026]}