5 "execution_count": null,
9 "from scipy import misc\n",
10 "import numpy as np\n",
11 "import matplotlib.pyplot as plt\n",
13 "from mpl_toolkits.mplot3d import Axes3D\n",
20 "execution_count": null,
24 "im = np.loadtxt('paws.numpy')\n",
25 "im = misc.imresize(im, 2.0)\n",
26 "im = im * (255 / np.max(im))"
31 "execution_count": null,
35 "g0 = imagepers.persistence(im)\n",
41 "execution_count": null,
45 "fig = plt.figure()\n",
46 "plt.imshow(im, interpolation=\"nearest\")\n",
48 "xx, yy = np.mgrid[0:im.shape[0], 0:im.shape[1]]\n",
50 "#fig = plt.figure()\n",
51 "#plt.contourf(xx, yy, im, np.arange(0, 255, 20))"
56 "execution_count": null,
60 "fig = plt.figure()\n",
61 "ax = fig.add_subplot(111)\n",
62 "ax.set_title(\"Peristence diagram\")\n",
63 "ax.plot([0,255], [0,255], '-', c='grey')\n",
64 "for i, homclass in enumerate(g0):\n",
65 " p_birth, bl, pers, p_death = homclass\n",
69 " x, y = bl, bl-pers\n",
70 " ax.plot([x], [y], '.', c='b')\n",
71 " ax.text(x, y+2, str(i+1), color='b')\n",
72 "ax.set_xlabel(\"Birth level\")\n",
73 "ax.set_ylabel(\"Death level\")\n",
74 "ax.set_xlim((-5,260))\n",
75 "ax.set_ylim((-5,260))"
80 "execution_count": null,
84 "fig = plt.figure()\n",
85 "ax = fig.add_subplot(111)\n",
86 "ax.set_title(\"Loci of births\")\n",
87 "for i, homclass in enumerate(g0):\n",
88 " p_birth, bl, pers, p_death = homclass\n",
89 " if pers <= 20.0:\n",
92 " ax.plot([x], [y], '.', c='b')\n",
93 " ax.text(x, y+0.25, str(i+1), color='b')\n",
95 "ax.set_xlim((0,im.shape[1]))\n",
96 "ax.set_ylim((0,im.shape[0]))\n",
97 "plt.gca().invert_yaxis()"
102 "execution_count": null,
106 "fig = plt.figure()\n",
107 "ax = fig.gca(projection='3d')\n",
108 "ax.plot_surface(xx, yy, im ,rstride=1, cstride=1, cmap=plt.cm.jet,\n",
114 "execution_count": null,
123 "execution_count": null,
133 "display_name": "Python 3",
134 "language": "python3.5",
142 "file_extension": ".py",
143 "mimetype": "text/x-python",
145 "nbconvert_exporter": "python",
146 "pygments_lexer": "ipython3",