Exemple #1
0
im = X_train[im_idx][None, :, :]

binarizer = Binarizer(threshold=0.4)

im_binarized = binarizer.fit_transform(im)

binplot = binarizer.plot(im_binarized)

binplot.update_layout(template='plotly_dark')

# Radial Filtration

radial_filtration = RadialFiltration(center=np.array([20, 6]))

im_filtration = radial_filtration.fit_transform(im_binarized)

radplot = radial_filtration.plot(im_filtration, colorscale="jet")

radplot.update_layout(template='plotly_dark')

# PLOTS

st.subheader("")
st.write(binplot)
st.subheader("Figure 1. Binarized Plot")
st.subheader("")

st.subheader("")
st.write(radplot)
st.subheader("Figure 2. Radial Filtration Plot")
def test_radial_transform(center, images, expected):
    radial = RadialFiltration(center=center)

    print(radial.fit_transform(images))

    assert_almost_equal(radial.fit_transform(images), expected)
Exemple #3
0
# 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)
a.set_title("Radial filtration")
imgplot = plt.imshow(X_rf[4], cmap="viridis")