Using the flooding watershed

Dear all, I am trying to write a that mimics the behavior of ImageJ's flooding watershed. This is how they describe it ( https://imagej.nih.gov/ij/docs/menus/process.html#watershed): *Watershed* *Watershed segmentation is a way of automatically separating or cutting apart particles that touch. It first calculates the Euclidian distance map (EDM) and finds the ultimate eroded points (UEPs). It then dilates each of the UEPs (the peaks or local maxima of the EDM) as far as possible - either until the edge of the particle is reached, or the edge of the region of another (growing) UEP. Watershed segmentation works best for smooth convex objects that don't overlap too much.* I tried to implement that (more or less), using the local minima (as pointed in https://www.mathworks.com/help/images/ref/bwulterode.html). Of course, there is something wrong :) from scipy.ndimage import binary_fill_holes from scipy.ndimage.morphology import distance_transform_edt from skimage.feature import peak_local_max from skimage.filters import threshold_otsu from skimage.io import imread from skimage.measure import label from skimage.morphology import disk, watershed from skimage.util import invert import matplotlib.pyplot as plt image = imread('K90_incid4,5min_1.bmp') img_bin = binary_fill_holes(image < threshold_otsu(image)) inv_bin = invert(img_bin) inv_dist = distance_transform_edt(inv_bin) inv_peak = peak_local_max(-inv_dist, indices=False) markers = label(peak) labels = watershed(-distance, markers, mask=img_bin, watershed_line=True) plt.imshow(labels, cmap='nipy_spectral'), plt.show() We don't have a function for UEPs in skimage yet, right? How could I implement this flooding watershed? Thank you very much. Kind regards, Alex -- -------------------------------------------------- Dr. Alexandre 'Jaguar' Fioravante de Siqueira Grupo de Cronologia - Sala 13 Departamento de Raios Cósmicos e Cronologia - DRCC Instituto de Física "Gleb Wataghin" - IFGW Unicamp - Universidade Estadual de Campinas Rua Sérgio Buarque de Holanda, 777 Cidade Universitária Zeferino Vaz - CEP 13083-859 Campinas - SP - Brazil Phone: +55(19)3521-5362 Lattes curriculum: 3936721630855880 <http://lattes.cnpq.br/3936721630855880/> ORCID: 0000-0003-1320-4347 <http://orcid.org/0000-0003-1320-4347> Personal site: programmingscience.org <http://www.programmingscience.org/> Github: alexandrejaguar <http://www.github.com/alexandrejaguar/> Skype: alexandrejaguar Twitter: alexdesiqueira <http://www.twitter.com/alexdesiqueira/> --------------------------------------------------
participants (1)
-
Alexandre Fioravante de Siqueira