Wolfram Language

Bild- und Signalverarbeitung

Die Form von Ländern vergleichen

Ermitteln Sie mit CanonicalWarpingDistance Ähnlichkeiten zwischen den Formen verschiedener Länder.

In[1]:=
Click for copyable input
names = {"USA", "Poland", "Portugal", "Vietnam", "Brazil", "Finland"}; borders = <|# -> ArrayResample[CountryData[#, "Polygon"][[1, 1, 1]], 200] & /@ names|>;
In[2]:=
Click for copyable input
shapes = Graphics[CountryData[#, "Shape"][[1]], ImageSize -> {50, 50}] & /@ Keys[borders]
Out[2]=

Berechnen Sie die Formdistanzen mithilfe der kanonischen Time Warping-Funktion.

In[3]:=
Click for copyable input
dm = DistanceMatrix[Values[borders], DistanceFunction -> (Chop[ CanonicalWarpingDistance[##, MaxIterations -> 6]] &)];

Veranschaulichen Sie die Distanzmatrix.

In[4]:=
Click for copyable input
MatrixPlot[dm, FrameTicks -> {{MapIndexed[{#2[[1]], #1} &, shapes], None}, {MapIndexed[{#2[[1]], Rotate[#1, \[Pi]/4]} &, names], None}}, Mesh -> True, ColorFunction -> "BlueGreenYellow", PlotLegends -> Automatic, PlotLabel -> "Distance based on country shape", ImageSize -> Medium]
Out[4]=

Verwandte Beispiele

en es fr ja ko pt-br ru zh