Segmentation algorithms

109 views
Skip to first unread message

Andreas Mueller

unread,
Jun 15, 2012, 10:29:55 AM6/15/12
to scikit...@googlegroups.com
Hi everybody.
I was wondering whether you are interested in having more image
segmentation algorithms in skimage.
As far as I can see, there is mainly watershed there at the moment.

I'd like to implement mean shift, quick shift, Felsenzwalb's graph based
method and a k-means based method.
Some of these are particularly interesting for super pixel creation.

Also: is there a strong desire do support both 2d and 3d images? (or
even n-d?)
I haven't been following the project to closely recently.

Cheers,
Andy

Zachary Pincus

unread,
Jun 15, 2012, 10:41:19 AM6/15/12
to scikit...@googlegroups.com
I think a stable of basic segmentation algorithms would be a really useful addition!

I'm agnostic on whether they ought to support 3d/nd also...

Zach

Emmanuelle Gouillart

unread,
Jun 15, 2012, 11:17:37 AM6/15/12
to scikit...@googlegroups.com
Hi Andy,

we would love to have more segmentation algorithms! In addition to the
watershed, there is also the random walker algorithm which can be more
robust for noisy images, with weak contours.

Since I'm using skimage for processing mostly 3-D images (from X-ray
tomography), I'm strongly biased towards 3-D support. But in fact, it's
only worth implementing an algorithm for 3-D images if it's fast enough
and does not have too high a memory load, since the data are much
larger (nobody wants to wait one day for the segmentation of a
1000*1000*1000 image... whereas one minute for a 1000x1000 image might
still be decent enough in 2-D). About n-d I don't know. The random
walker, for example, works for 2-D and 3-D ndarrays.

Looking forward to your new segmentation algorithms :-)!

Cheers,
Emmanuelle

Andreas Mueller

unread,
Jun 15, 2012, 11:34:00 AM6/15/12
to scikit...@googlegroups.com
Hi Emanuelle and Zachary.
Thanks for the positive feedback.
@Emanuelle: Are there examples in scikit-image for using 3d images?
I didn't find anything in the gallery.

I am not very familiar with this kind of data but if I have some "typical"
case, I can see how it goes.

Cheers,
Andy

Andreas Mueller

unread,
Jun 15, 2012, 1:53:02 PM6/15/12
to scikit...@googlegroups.com
Hi everybody.
One more question before I dig into the code:
What is your stance on pep8? I saw that it is not followed everywhere in
the code.
Should new code adhere to pep8?
In scikit-learn, I'm a bit of a nazi when it comes to that ;)

Cheers,
Andy

Tony Yu

unread,
Jun 15, 2012, 2:04:32 PM6/15/12
to scikit...@googlegroups.com
Hi Andy,

We definitely try to follow PEP8 and the numpy docstring standard. Sometimes that gets overlooked in code review, but it's usually best to follow these conventions.

Looking forward to seeing some pull requests :)

Cheers,
-Tony

Stéfan van der Walt

unread,
Jun 15, 2012, 2:46:01 PM6/15/12
to scikit...@googlegroups.com
Hi Andreas

On Fri, Jun 15, 2012 at 10:53 AM, Andreas Mueller
<amue...@ais.uni-bonn.de> wrote:
> One more question before I dig into the code:
> What is your stance on pep8? I saw that it is not followed everywhere in the
> code.
> Should new code adhere to pep8?
> In scikit-learn, I'm a bit of a nazi when it comes to that ;)

We encourage the use of PEP08, but also to use good judgement with the
aim of writing well readable code. I.e., some parts of PEP08 are more
important than others (personally, I don't care all that much about
two blank lines between functions and even prefer the exponent to be
close to the base, a**2). That said, any PEP08 cleanups are welcome.

Stéfan

Stéfan van der Walt

unread,
Jun 15, 2012, 2:47:43 PM6/15/12
to scikit...@googlegroups.com
Hi Andreas

On Fri, Jun 15, 2012 at 7:29 AM, Andreas Mueller
<amue...@ais.uni-bonn.de> wrote:
> I was wondering whether you are interested in having more image segmentation
> algorithms in skimage.

I am also very interested in matting algorithms and graph cuts, e.g.:

http://www.inf.ufrgs.br/~eslgastal/SharedMatting/

Stéfan

Andreas Mueller

unread,
Jun 15, 2012, 3:06:27 PM6/15/12
to scikit...@googlegroups.com
Hi Stefan.
In the near future I also want to implement Boykov-Kolmogorov
and graph cuts. I think it would be nice to to GrabCut with sklearn+skimage.
Let's see how this goes.

Cheers,
Andy

Btw: I also like n**2 better but then my editor complains ;)
> St�fan

Emmanuelle Gouillart

unread,
Jun 15, 2012, 4:28:07 PM6/15/12
to scikit...@googlegroups.com
Hi Andy,

> @Emanuelle: Are there examples in scikit-image for using 3d images?
> I didn't find anything in the gallery.

no, there are no examples with 3-D images. The main reason why I didn't
write any such 3-D example is that visualization of the result would best
be done with Mayavi, and since the code of the examples is executed when
the doc is built, there will be errors if mayavi is not installed. But
the principle of a segmentation algorithm is often the same in 2-D and in
3-D. The example
http://scikits-image.org/docs/dev/auto_examples/plot_random_walker_segmentation.html
could have been done on a similar 3-D image.

I could, however, write a tutorial on how to deal with the processing of
3-D images with numpy/skimage/mayavi...

> I am not very familiar with this kind of data but if I have some "typical"
> case, I can see how it goes.

3-D data that I'm aware of are mostly medical images and materials science
image (MRI, CT, FIB). Compared to 2-D images, we usually do not have such
things as "natural 3-D images", and images are more "homogeneous". (I
hope I'm not saying too much nonsense -- what I mean is that usually you
do not try to detect people or faces in 3-D images! But I might have a
too limited viewpoint.).

In Python/skimage, these 3-D images would be just 3-D arrays (usually 3-D
images are in grayscale and not in color), with the array values
corresponding to the pixel values (actually, a pixel is called voxel in
3-D).

If you start working on 2-D algorithms, I can give you a hand to see
whether it would be relevant to have them in 3-D as well, and how to do it.

Cheers,
Emmanuelle

Jérôme Kieffer

unread,
Jun 16, 2012, 4:33:08 AM6/16/12
to scikit...@googlegroups.com
Hi,

I have a very simple algorithm for segmenting images, based on gaussian blurring and could be made available in skimage (implies a change of licence but it's not an issue on my side).

This algorithm is probably not new and has probably a name that I don't know. It uses small pieces of Cython for speed and fftw if possible (scipy.ndimage.filters.gaussian_filter if not)

Segmenting a 1kx1k image is done in 1s, larger images are usually binned to 1kx1k then unbinned to the original size.

Beside the input image, the code needs a "typical valley size" to isolate groups of peaks form each other.

Cheers,
--
Jérôme Kieffer <goo...@terre-adelie.org>
PS: see Massif in https://github.com/kif/pyFAI/blob/master/pyFAI-src/peakPicker.py

Jaidev Deshpande

unread,
Jun 16, 2012, 4:57:15 AM6/16/12
to scikit...@googlegroups.com
Hi,

> Should new code adhere to pep8?

When you say new code, are you referring to all new code in general,
or some specific package? And out of curiosity, why is this message on
the scikit-image mailing list?

Thanks

Andreas Mueller

unread,
Jun 16, 2012, 8:11:44 AM6/16/12
to scikit...@googlegroups.com
Hi Jaidev.
To answer both of your questions:
I was refering to code in scikit-image and the policy / opinions of
scikit-image devs about these issues.

Cheers,
Andy

Emmanuelle Gouillart

unread,
Jun 18, 2012, 7:18:06 AM6/18/12
to scikit...@googlegroups.com
Hi J�r�me,

for which kind of images / objects to be segmented is this algorithm
suited for? Do you have an example script?

Cheers,
Emmanuelle

off-topic PS: I'll be at the ESRF synchrotron next week, from Tuesday
26th to the end of the week. See you there next week, maybe!

Jérôme Kieffer

unread,
Jun 18, 2012, 2:13:45 PM6/18/12
to scikit...@googlegroups.com
On Mon, 18 Jun 2012 13:18:06 +0200
Emmanuelle Gouillart <emmanuelle...@nsup.org> wrote:

> Hi Jérôme,
>
> for which kind of images / objects to be segmented is this algorithm
> suited for? Do you have an example script?

I tweeked a bit the original image to have something showing up (np.log(a.clip(1,1000)).
Then I run the segmenting
>
> off-topic PS: I'll be at the ESRF synchrotron next week, from Tuesday
> 26th to the end of the week. See you there next week, maybe!

If you can manage to come earlyer: we are organizing a workshop of the deployment of Debian in science facilities on monday+tuesday...

See you.

--
Jérôme Kieffer <goo...@terre-adelie.org>
fairchild.jpg
labeled.jpg
Reply all
Reply to author
Forward
0 new messages