Beispiel #1
0
def test_height_transform(direction, images, expected):
    height = HeightFiltration(direction=direction)

    assert_almost_equal(height.fit_transform(images),
                        expected)
Beispiel #2
0
X_bin = X

# X_index = np.zeros((40000, 28, 28))
# for i in tqdm(range(40000)):
#     img = X[i]
#     x_arr, y_arr = np.nonzero(img)
#     X_index[i] = np.array([x_arr, y_arr]).T

hf = HeightFiltration()
df = DilationFiltration()
rf = RadialFiltration(np.array([8, 15]))
X_used = X_bin
y_used = y

## Create the Filtrations
X_hf = hf.fit_transform(X_used, y_used)
X_df = df.fit_transform(X_used, y_used)
X_rf = rf.fit_transform(X_used, y_used)

fig = plt.figure()
fig.set_size_inches((12, 9))
a = fig.add_subplot(2, 2, 1)
a.set_title("Height filtration")
imgplot = plt.imshow(X_hf[4], cmap="viridis")
a = fig.add_subplot(2,2, 2)
a.set_title("Dilation filtration")
imgplot = plt.imshow(X_df[4], cmap="viridis")
a = fig.add_subplot(2,2, 3)
a.set_title("Binary")
imgplot = plt.imshow(X_bin[4], cmap="binary")
a = fig.add_subplot(2,2, 4)