[scikit-image] scikit-image Digest, Vol 13, Issue 2

Alexandre Fioravante de Siqueira siqueiraaf at gmail.com
Thu Oct 5 10:06:45 EDT 2017


Hi all,
Thomas, thank you for your help, and sorry for not sending the image. It
follows attached.
I applied the threshold that way because I'm interested in the "black
spots" in the image.
Thank you again. I'll try to run the code using your insights.
Kind regards,

Alex

PS.: Could you tell a little more about the errors in ImageJ's description?
Thank you for that!

On Thu, Oct 5, 2017 at 11:00 AM, <scikit-image-request at python.org> wrote:

> Send scikit-image mailing list submissions to
>         scikit-image at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/scikit-image
> or, via email, send a message with subject or body 'help' to
>         scikit-image-request at python.org
>
> You can reach the person managing the list at
>         scikit-image-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of scikit-image digest..."
>
> Today's Topics:
>
>    1. Using the flooding watershed (Alexandre Fioravante de Siqueira)
>    2. Re: Using the flooding watershed (Thomas Walter)
>
>
> ---------- Forwarded message ----------
> From: Alexandre Fioravante de Siqueira <siqueiraaf at gmail.com>
> To: scikit-image at python.org
> Cc:
> Bcc:
> Date: Thu, 5 Oct 2017 10:22:39 -0300
> Subject: [scikit-image] 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 <+55%2019%203521-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/>
> --------------------------------------------------
>
>
> ---------- Forwarded message ----------
> From: Thomas Walter <Thomas.Edgar.Walter at googlemail.com>
> To: scikit-image at python.org
> Cc:
> Bcc:
> Date: Thu, 5 Oct 2017 15:41:18 +0200
> Subject: Re: [scikit-image] Using the flooding watershed
> Hello Alex,
>
> the ultimate erosion coincides with the local maxima of the distance map
> (or the local minima of the inverse distance map).
>
> In skimage, you can get these by:
>
> from skimage.morphology import extremalocal_maxima = extrema.local_maxima <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.local_maxima>(distance_map)
>
>
> peak_local_max is not equivalent to the UEP, but can be preferable in
> certain situations.
>
> I did not check your example in practice as I do not have the image, but I
> was a bit confused by the inversions, as you start by applying the
> threshold the other way around.
>
> Best,
>
> Thomas.
>
> P.S.: The ImageJ description is not correct, which I have always found
> disturbing. The Watershed algorithm is of course not limited to
> applications to the inverse distance map.
>
>
> On 10/5/17 3:22 PM, Alexandre Fioravante de Siqueira wrote:
>
> 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 <+55%2019%203521-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/>
> --------------------------------------------------
>
>
> _______________________________________________
> scikit-image mailing listscikit-image at python.orghttps://mail.python.org/mailman/listinfo/scikit-image
>
>
>
> --
> Thomas Walter
> 27 rue des Acacias
> 75017 Paris
>
>
> _______________________________________________
> scikit-image mailing list
> scikit-image at python.org
> https://mail.python.org/mailman/listinfo/scikit-image
>
>


-- 
--------------------------------------------------
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/>
--------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20171005/b3cfe4ca/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: K90_incid4,5min_1.bmp
Type: image/bmp
Size: 441910 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20171005/b3cfe4ca/attachment-0001.bin>


More information about the scikit-image mailing list