-3
$\begingroup$

The command

ImageDistance[Plot[x^2, {x, 0, 1}, PlotRange -> {0, 1.01}], 
Plot[x^2 + 0.01, {x, 0, 1}, PlotRange -> {0, 1.01}]]

produces 33.3253. Unfortunately, the Mathematica help to ImageDistance says nothing how the distance is calculated. The images are very similar.

$\endgroup$
  • 1
    $\begingroup$ The documentation for ImageDistance's "Details and Options" says that EuclideanDistance is the default. You can give a different DistanceFunction as an option. $\endgroup$ – Carl Lange Mar 6 at 17:08
  • $\begingroup$ Yes, but what is it? Which formulas are applied to this end? $\endgroup$ – user64494 Mar 6 at 17:09
  • 2
    $\begingroup$ @user64494 I cast a downvote because, in my opinion, yours is not a question, but an observation. I am not sure what you would consider an acceptable answer, short of providing documentation that is currently not available to us. Perhaps it would be more useful to bring this issue up with Wolfram Support, if your goal is to have better documentation. Additionally, this may turn out to be an XY problem, i.e. you are asking about your perceived solution of a problem, rather than about the issue itself that you are having. $\endgroup$ – MarcoB Mar 6 at 19:03
  • 1
    $\begingroup$ @MarkoB: My question was inspired by a too poor Mathematica documentation to ImageDistance, where I didn't find an answer. I followed your advice concerning Wolfram Support. $\endgroup$ – user64494 Mar 6 at 19:13
  • 1
    $\begingroup$ If your arguments are Graphics, then I believe ImageDistance is doing the following: id[i1_,i2_]:=EuclideanDistance[ Flatten @ ImageData @RemoveAlphaChannel[Image[i1],Black], Flatten @ ImageData @RemoveAlphaChannel[Image[i2],Black] ] $\endgroup$ – chuy Mar 6 at 19:26
7
$\begingroup$

The documentation for ImageDistance's "Details and Options" says that EuclideanDistance is the default. You can give a different DistanceFunction as an option.

You can replicate what ImageDistance is doing by default like so:

i1 = Rasterize@Plot[x^2, {x, 0, 1}, PlotRange -> {0, 1.01}];
i2 = Rasterize@Plot[x^2 + 0.01, {x, 0, 1}, PlotRange -> {0, 1.01}];

Then,

ImageDistance[i1, i2]

25.6833

EuclideanDistance[Flatten@ImageData@i1, Flatten@ImageData@i2]

25.6833

We can do the same with other distance functions, for example:

ImageDistance[i1, i2, DistanceFunction -> CorrelationDistance]

0.245972

CorrelationDistance[Flatten@ImageData@i1, Flatten@ImageData@i2]

0.245972

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.