Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Wolfram Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • System Modeler
  • Wolfram Player
  • Finance Platform
  • Wolfram Engine
  • Enterprise Private Cloud
  • Application Server
  • Wolfram|Alpha Notebook Edition
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

WolframConsulting.com

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Wolfram Notebook Assistant + LLM Kit
    • System Modeler
    • Wolfram Player
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Wolfram Engine
    • Enterprise Private Cloud
    • Application Server
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
ImageDistance
  • See Also
    • ImageDifference
    • ImageSubtract
    • ColorDistance
    • ImageAlign
    • FeatureDistance
    • FeatureNearest
    • Nearest
    • CentralFeature
  • Related Guides
    • Geometric Operations
    • Distance and Similarity Measures
    • See Also
      • ImageDifference
      • ImageSubtract
      • ColorDistance
      • ImageAlign
      • FeatureDistance
      • FeatureNearest
      • Nearest
      • CentralFeature
    • Related Guides
      • Geometric Operations
      • Distance and Similarity Measures

ImageDistance[image1,image2]

returns a distance measure between image1 and image2.

ImageDistance[image1,image2,pos]

places the center of image2 at position pos in image1.

ImageDistance[image1,image2,pos1,pos2]

places the point pos2 of image2 at position pos1 in image1.

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
DistanceFunction  
Masking  
Applications  
Properties & Relations  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • ImageDifference
    • ImageSubtract
    • ColorDistance
    • ImageAlign
    • FeatureDistance
    • FeatureNearest
    • Nearest
    • CentralFeature
  • Related Guides
    • Geometric Operations
    • Distance and Similarity Measures
    • See Also
      • ImageDifference
      • ImageSubtract
      • ColorDistance
      • ImageAlign
      • FeatureDistance
      • FeatureNearest
      • Nearest
      • CentralFeature
    • Related Guides
      • Geometric Operations
      • Distance and Similarity Measures

ImageDistance

ImageDistance[image1,image2]

returns a distance measure between image1 and image2.

ImageDistance[image1,image2,pos]

places the center of image2 at position pos in image1.

ImageDistance[image1,image2,pos1,pos2]

places the point pos2 of image2 at position pos1 in image1.

Details and Options

  • ImageDistance[image1,image2] centers image2 in image1 and returns the distance between the overlapping regions in the two images.
  • ImageDistance works with arbitrary 2D and 3D images.
  • Images should either have the same number of channels or one should be a single-channel image. If either of image1 or image2 is a single-channel image, the channel is replicated to match the number of channels in the other image.
  • Position specification pos can be of the form:
  • {x,y} or {x,y,z}absolute pixel position
    Scaled[{sx,…}]scaled position from 0 to 1 across the object
    Centercenter alignment
    Left,Right axis in both 2D and 3D
    Bottom,Top axis in 2D, axis in 3D
    Front,Back axis in 3D
    {posx,…}a list of named positions
  • If alignment along each axis is not given, it is assumed to be Center.
  • The following options can be given:
  • DistanceFunction EuclideanDistancedistance function to use
    Masking Allregion of interest
  • Some typical distance function settings include:
  • EuclideanDistanceEuclidean distance (default)
    SquaredEuclideanDistancesquared Euclidean distance
    NormalizedSquaredEuclideanDistancenormalized squared Euclidean distance
    ManhattanDistanceManhattan or "city block" distance
    CosineDistanceangular cosine distance
    CorrelationDistancecorrelation coefficient distance
    ffunction f that is given the overlapping regions of the two images as arguments
  • The following special distance functions are also supported:
  • "MeanEuclideanDistance"mean Euclidean distance
    "MeanSquaredEuclideanDistance"mean squared Euclidean distance
    "RootMeanSquare"mean squared root distance
    {"MeanReciprocalSquaredEuclideanDistance",λ}one minus the mean of the robust distances , where is the Euclidean distance of corresponding pixels (default )
    {"MutualInformationVariation",n}joint entropy minus mutual information using n-bin histogram (default )
    {"NormalizedMutualInformationVariation",n}the mutual information variation divided by the joint entropy using n-bin histogram (default )
    {"DifferenceNormalizedEntropy",n}entropy of the difference image using n-bin histogram (default )
    "MeanPatternIntensity"mean local pattern intensity difference
    "GradientCorrelation"mean of the correlation distances between the spatial derivatives
    "MeanReciprocalGradientDistance"one minus the mean of the distances , with values and variances of the spatial derivatives along dimension s of imagei
    {"EarthMoverDistance",n}earth mover distance using n-bin histogram
  • Using Masking->roi, a region of interest in image1 is specified. With Masking->{roi1,roi2}, the intersection of roi1 and roi2 on the overlapped images is used.
  • Predefined ImageDistance metrics are symmetric and non-negative. However, some distances may not satisfy the triangle inequality. The distance between two images can be 0 with some methods, even if they are not identical. User-defined functions might break these properties.
  • If there are no overlapping regions or the measure cannot be determined, Indeterminate is returned. »

Examples

open all close all

Basic Examples  (2)

Euclidean distance between two images:

Euclidean distance between 3D images:

Scope  (2)

By default, images are center aligned:

Align the top-left corner of the first image with the center of the second image:

Align the center top of the first image and right center of the second image:

Specify positions using the standard coordinate system:

Specify positions using scaled coordinates:

Specify the alignment position for 3D images:

Options  (8)

DistanceFunction  (5)

Use a custom distance function:

Use a custom distance function with masks:

Earth mover distance:

Use histograms with four bins per channel:

Compare different distance measures:

Compute the root mean square distance of approximate perceptual distances between pixels:

Masking  (3)

Use a mask to specify the region of interest in the first image:

Use a mask to specify the region of interest in the second image:

Use masks for both images:

Applications  (2)

Construct a similarity graph of a set of images based on the earth mover distance:

Compute a matrix of distances for all image pairs:

Threshold the distances to construct an adjacency matrix and visualize using a graph:

Register two images related by a translation and a rotation:

Properties & Relations  (8)

The distance between an image and itself is always zero:

The distance between two different images may be 0:

The distance between two images is symmetric:

The distance may not be symmetric with masks:

When the images have no overlap, the distance is indeterminate:

The distance between an image and its rotations:

Normalized mutual information variation of an MRI and a translated PET image:

Correcting for overall change in brightness is a typical preprocessing with some distances:

Without correction, it is less apparent that the two images are aligned:

Some distance measures are effectively invariant to specific transformations.

Spatial reflection:

Color negation:

Pointwise addition:

Pointwise multiplication by a positive number:

Pointwise affine transformation with positive slope coefficient:

For a rectangular mask, image distance is equal to the distance of the trimmed images:

See Also

ImageDifference  ImageSubtract  ColorDistance  ImageAlign  FeatureDistance  FeatureNearest  Nearest  CentralFeature

Related Guides

    ▪
  • Geometric Operations
  • ▪
  • Distance and Similarity Measures

History

Introduced in 2012 (9.0) | Updated in 2014 (10.0) ▪ 2016 (10.4)

Wolfram Research (2012), ImageDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageDistance.html (updated 2016).

Text

Wolfram Research (2012), ImageDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageDistance.html (updated 2016).

CMS

Wolfram Language. 2012. "ImageDistance." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ImageDistance.html.

APA

Wolfram Language. (2012). ImageDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageDistance.html

BibTeX

@misc{reference.wolfram_2025_imagedistance, author="Wolfram Research", title="{ImageDistance}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ImageDistance.html}", note=[Accessed: 01-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_imagedistance, organization={Wolfram Research}, title={ImageDistance}, year={2016}, url={https://reference.wolfram.com/language/ref/ImageDistance.html}, note=[Accessed: 01-December-2025]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Player
  • Wolfram Engine

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2025 Wolfram
© 2025 Wolfram | Legal & Privacy Policy |
English