Topics

Persistence Diagram of an image

Hajar Bouazzaoui
 

I am trying to get the persistence diagram of an image by building lower star filtrations on the Freudenthal triangulation of a grayscale image (which is basically a numpy array) using the following code

import PIL  
im = np.asarray(PIL.Image.open('im1.jpg'))
image1_grey = np.asarray(PIL.Image.fromarray(im).convert('L'))
f_lower_star = d.fill_freudenthal(image1_grey)
(At this stage I'm getting Unknown array dtype
p = d.homology_persistence(f_lower_star)
 dgms = d.init_diagrams(p, f_lower_star)
d.plot.plot_diagram(dgms[0])

I'm not even sure I'm following the right approach to get the persistence diagram
Would you please guide me?



Dmitriy Morozov
 

Can you try the following?

image1_grey = np.asarray(PIL.Image.fromarray(im).convert('L'), dtype='f4')

(Note the extra dtype argument.)


On Fri, Jan 25, 2019 at 6:06 AM Hajar Bouazzaoui <contact.bouazzaoui@...> wrote:
I am trying to get the persistence diagram of an image by building lower star filtrations on the Freudenthal triangulation of a grayscale image (which is basically a numpy array) using the following code

import PIL  
im = np.asarray(PIL.Image.open('im1.jpg'))
image1_grey = np.asarray(PIL.Image.fromarray(im).convert('L'))
f_lower_star = d.fill_freudenthal(image1_grey)
(At this stage I'm getting Unknown array dtype
p = d.homology_persistence(f_lower_star)
 dgms = d.init_diagrams(p, f_lower_star)
d.plot.plot_diagram(dgms[0])

I'm not even sure I'm following the right approach to get the persistence diagram
Would you please guide me?



Hajar Bouazzaoui
 

Thank you so much! it worked!