An example for 2D and 3D Digital Images #27
Replies: 1 comment 2 replies
-
Dear Aras, Thanks for your interest in this library :) import gudhi as gd
import multipers as mp
import numpy as np
# Data
num_parameters = 3
res = (10,20,30,num_parameters)
img = np.random.uniform(size=res)
#Triangulation
mesh = np.meshgrid(*[np.arange(r) for r in res[:-1]])
X = np.concatenate(tuple(stuff.ravel()[:,None] for stuff in mesh), axis=1)
ac = gd.AlphaComplex(points = X)
st = ac.create_simplex_tree()
p = np.fromiter((ac.get_point(i) for (i,),f in st.get_skeleton(0)), dtype=np.dtype((int,img.ndim-1)))
assert np.all(p == X) # alpha complex may reorder points, it doesn't seem to be the case here
# To multipers
st = mp.SimplexTreeMulti(st, num_parameters = num_parameters,dtype=np.float64)
for i in range(num_parameters):
st.fill_lowerstar(img[...,i].ravel(),parameter = i) which will give you a topologically equivalent simplicial complex. Note that in the 2-parameter case, you'll have access to edge collapses, and minimal presentation, so this shouldn't hurt performance there. I currently have some issues with my website, so my email can be hard to find; you can contact me at david.loiseaux@inria.fr Best, |
Beta Was this translation helpful? Give feedback.
-
I would like to first thank you for your efforts in building this package.
It would be nice to have an example where the input is a 2D digital Image and plotting the corresponding Multiparameter representation. I searched in the docs/notebooks but could not find one.
I can provide medical images for a notebook to do the multiparameter representation of images and a set of images to do machine learning ( e.g. classification).
Best Wishes
Aras Asaad
P.S. : I could not find an email to directly contact you
I can be contacted by: aras.asaad@maths.ox.ac.uk
Beta Was this translation helpful? Give feedback.
All reactions