ImageDistance[image1, image2]
returns a distance measure between and .

ImageDistance[image1, image2, pos]
places the center of at position pos in .

ImageDistance[image1, image2, pos1, pos2]
places the point of at position in .

Details and OptionsDetails and Options

  • ImageDistance[image1, image2] centers in and returns the distance between the overlapping regions in the two images.
  • In ImageDistance[image1, image2], and should either have the same number of channels or one should be a single-channel image. If or is a single-channel image, the channel is replicated to match the number of channels in the other image.
  • ImageDistance accepts a DistanceFunction option. Some typical 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 settings are also supported:
  • "MeanEuclideanDistance"mean Euclidean distance
    "MeanSquaredEuclideanDistance"mean squared Euclidean distance (default)
    "MeanReciprocalSquaredEuclideanDistance"one minus the mean of the robust distances , where is the Euclidean distance of corresponding pixels
    "MutualInformationVariation"joint entropy minus mutual information
    "NormalizedMutualInformationVariation"the mutual information variation divided by the joint entropy
    "DifferenceNormalizedEntropy"entropy of the difference image
    "MeanPatternIntensity"mean local pattern intensity difference
    "GradientCorrelation"mean of the correlation distances between the horizontal and vertical derivatives
    "MeanReciprocalGradientDistance"one minus the mean of the distances and , where and are the values and and are the variance of the horizontal and vertical derivatives computed for
    "EarthMoverDistance"earth mover distance
  • With DistanceFunction->{"MeanReciprocalSquaredEuclideanDistance", }, 1 minus the mean of reciprocal distances is returned. By default, =1.
  • With , , , and methods, can be used to specify that n bins should be used in the histogram computation. By default, uses eight bins and all other methods use 256 bins.
  • With DistanceFunction->{"MeanPatternIntensity", , r}, the mean of the distances is computed for each pixel in the difference image , where is the Euclidean distance between and pixels in its range-r neighborhood. The overall distance is 1 minus the mean of the local distances. By default, and r=2.
  • ImageDistance is symmetric and non-negative. However, it may not satisfy the triangle inequality. The distance between two images can be 0 with some methods, even if they are not identical.
  • If there are no overlapping regions or the measure cannot be determined, ImageDistance returns Indeterminate. »
New to Mathematica? Find your learning path »
Have a question? Ask support »