Skip to content

ENH: add mean and triangle thresholding algorithms - #2124

Closed
sciunto wants to merge 3 commits into
scikit-image:masterfrom
sciunto:thres
Closed

sciunto wants to merge 3 commits into
scikit-image:masterfrom
sciunto:thres

Conversation

@sciunto

@sciunto sciunto commented Jun 1, 2016 •

Copy link
Copy Markdown
Member

Description

This PR adds two new algorithms:

  • mean (trivial)
  • triangle (less trivial).

Checklist

[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]

Comment thread skimage/filters/thresholding.py Outdated


def threshold_mean(image):
"""Return threshold value based on the of grayscale values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is missing.

@soupault

soupault commented Jun 1, 2016

Copy link
Copy Markdown
Member

@sciunto Thanks for the contribution! mean thresholding will be our killer-feature :trollface: .

What about gallery examples though? Would be nice to have one at least for the triangle method (applied to several images we ship).

@codecov-io

codecov-io commented Jun 1, 2016 •

Copy link
Copy Markdown

Current coverage is 90.53%

Merging #2124 into master will increase coverage by <.01%

@@             master      #2124   diff @@
==========================================
  Files           297        297          
  Lines         21166      21214    +48   
  Methods           0          0          
  Messages          0          0          
  Branches       1934       1936     +2   
==========================================
+ Hits          19157      19205    +48   
  Misses         1663       1663          
  Partials        346        346          

Powered by Codecov. Last updated by 71456ed...e2054ca

@sciunto

sciunto commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

@soupault Fixed. I really hope that the mean threshold will be printed in gold letters in the next announcement! :)

For the gallery, it's a good point. My opinion is that it's fairly useless to accumulate examples more or less identical to this one with few changes. Also, this will make the gallery page longer and therefore, it will more difficult to find something in there in the future.

Instead, I think that a more comprehensive page on thresholding will be more useful for users. This is part of the objectives for #2110, but maybe I will do that in an extra PR, because we already have several PRs on thresholding and it's difficult to handle everything in parallel.

Comment thread skimage/filters/thresholding.py Outdated
argrighth = np.where(hist>0)[0][-1]
# Find peak, lowest and highest gray levels.
arg_peak_hight = np.argmax(hist)
peak_height = hist[argpeak_height]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg_peak_hight + argpeak_height == arg_peak_height 😆

@sciunto sciunto Jun 1, 2016 via email

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soupault

soupault commented Jun 1, 2016 •

Copy link
Copy Markdown
Member

@sciunto Ah, now I see what are you up to...
I like your idea a lot! thresholding section of the documentation could be a very useful and informative thing to have.
So, this way we should have (1) the section mentioned above with the results of different algorithms on different images - so to give user an intuition what kind of thresholding do we have and do he or she needs, (2) try_all function to evaluate the algorithms on user images to refine his or her intuition and to help choosing the most suitable algorithm.
By the way, I remember that sklearn team has done something very similar for, for example, clustering.



def test_triangle_flip():
# Depending on the skewness, the agorithm flips the histogram.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*algorithm

@sciunto

sciunto commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

@soupault Thanks for your comments!

Do you agree to replace the check and the warning in threshold_otsu by assert_nD(image, 2)?

@soupault

soupault commented Jun 1, 2016

Copy link
Copy Markdown
Member

@sciunto let's keep otsu warning for another PR and discussion. Regarding that particular case you should bother @jni, Keeper, Guardian and Evangelist of n-dimensions, Honoured Member of the Hilbert Chamber.

@sciunto

sciunto commented Jun 2, 2016

Copy link
Copy Markdown
Member Author

Rebasing this is aweful. I'll open another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants