Repository navigation
ENH: try_all to choose the best threshold algorithm and DOC refactoring - #2110
Conversation
|
|
||
|
|
||
| def mosaic_global_threshold(image, figsize=None): | ||
| """Returns a figure with images generated from different methods. |
There was a problem hiding this comment.
Returns a figure comparing the outputs of different thresholding methods?
|
This is really cool! How about printing the names of the different skimage functions to use? Also, would it be possible to include adaptive thresholding in the default mosaic, with one or two values of the block size? I don't know if automatic methods exist to compute the best block size (which should be larger than the objects of interest but smaller than the global intensity gradient). |
|
I'm glad you appreciate it @emmanuelle. :) I can try to print the full name of the functions, I'm just a bit concerned by the length. For the adaptive threshold, I think it's a good idea. We can transform the code in my first post into a function. It could also includes a rank filter. As you said, my only concern is about the parameters. My last thoughts are:
|
|
About printing the name, I was thinking of printing in the Python shell, not about the titles of subfigures. |
|
@emmanuelle Done. Now, the output for the second example is: |
|
Thanks for the changes! A radius of 10 is maybe too small for an optimal thresholding with local methods, otherwise, LGTM. |
|
I switched to 20 for the example. Now, only the example uses this value. After I wrote the second function, I realized I could write only one and set the radius to None by default. If it's None, then, only histogram-based algorithms are called. I also started to illustrate this feature in the gallery. I'm also planning to refactor/merge some other examples to make something more comprehensive on thresholding. |
|
This is super cool. Thanks @sciunto! Are you done with the implementation? |
|
@sciunto nice feature! |
|
I made some work on the gallery. |
Current coverage is 90.58%@@ master #2110 diff @@
==========================================
Files 297 297
Lines 21291 21340 +49
Methods 0 0
Messages 0 0
Branches 1959 1963 +4
==========================================
+ Hits 19285 19331 +46
- Misses 1656 1657 +1
- Partials 350 352 +2
|
|
mean and triangle are integrated. I updated the syntax for sphinx-gallery. |
|
|
||
| Thresholding is used to create a binary image from a grayscale image [1]_. | ||
| If you are not familiar with the details of the different algorithms and the | ||
| underlying assumptions, it is often to know which algorithm will give the best |
|
I like it the way it is. Unless we are going to present slightly different use case, I see no need to duplicate the examples. |
|
|
||
|
|
||
|
|
||
|
|
|
Thanks for your comments :) I'll push tomorrow. |
|
I realized my imports were sloppy. I fixed that. |
|
@soupault @emmanuelle Fixed. |
|
Thanks! 👍 for merging |
|
@sciunto could you squash the commits, please? |
| @@ -1,10 +1,15 @@ | |||
| import math | |||
There was a problem hiding this comment.
Not clear why you need this import. There is numpy already.
There was a problem hiding this comment.
math is faster than numpy for scalars, it's therefore good practice to use it.
There was a problem hiding this comment.
In [2]: %timeit a = math.sqrt(100.)
The slowest run took 59.41 times longer than the fastest. This could mean that an intermediate result is being cached
10000000 loops, best of 3: 68.2 ns per loop
In [3]: %timeit a = np.sqrt(100.)
The slowest run took 27.52 times longer than the fastest. This could mean that an intermediate result is being cached
1000000 loops, best of 3: 511 ns per loop
There was a problem hiding this comment.
OK, doesn't make a huge difference, but say you have a function that's going to be called zillions of times, then you should really use math instead of numpy.
|
I squashed the last ones. I kept the others to keep the granularity. There is a lot of addition/deletion ;) |
|
Thanks @sciunto! |
|
Yeehaa ! |
Description
For a while, I wanted a feature similar to imagej, called try_all. As a user, it's convenient to visualize the effect of different thresholding algorithms to find the best one.
Here is an example (updated):
I open this to start discussions.
Checklist
doc/examples/segmentation/plot_otsu.py).