Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: implement generalized histogram thresholding #5189

Open
jni opened this issue Jan 18, 2021 · 11 comments
Open

Feature request: implement generalized histogram thresholding #5189

jni opened this issue Jan 18, 2021 · 11 comments

Comments

@jni
Copy link
Member

jni commented Jan 18, 2021

Description

There was a badass paper last year that unified and generalized Otsu and other thresholding methods (arXiv).

As usual, since it's a new algorithm the argument can be made that we should wait to see it in practice, but my gut feeling is that (a) it's really good, and (b) it's a generalization of an existing algorithm that we have in the library, so it does not add much code, and minimum error thresholding (Kittler & Illingworth, 1986) is also generalized by this method, so we would automatically gain an implementation of a thresholding algorithm that has 2600+ citations.

So, I would vote to include it in the library, e.g. as threshold_generalized_histogram. Furthermore, since there is Apache-licensed code available already (notebook), this might be a good first issue for someone who wants to get started contributing to the library.

@Monishver
Copy link

Hello @jni , I'm new to open source and would like to make my first contribution to the community. Can you explain this issue in detail.

@sciunto
Copy link
Member

sciunto commented Jan 19, 2021

@Monishver The main idea is:

  • implement the function (based on the notebook) with a full docstring.
  • add unittests
  • add an example in the gallery

@jni
Copy link
Member Author

jni commented Jan 19, 2021

@Monishver have you seen our contributing guide?

https://scikit-image.org/docs/dev/contribute.html

Please let us know if you have more questions after reading this!

@Monishver
Copy link

Thanks, @sciunto and @jni for helping me get started, I will look into it and get back to you if I have any doubts.

@divyank0
Copy link
Contributor

I guess I can close this. :)

@jni
Copy link
Member Author

jni commented Mar 16, 2021

@divyank0 that would be much appreciated! 🎉

@divyank0
Copy link
Contributor

I am preparing the ticket , few questions I have

  • What is meant by ndarray : (N, M[, …, P])

@divyank0
Copy link
Contributor

I am wondering what could be ideal signature for the function

def theshold_generalized_histogram(n, x=None, nu=0, tau=0, kappa=0, omega=0.5):
or
def theshold_generalized_histogram(image, x=None)

where x is the array of bin intensities , n is histogram and others are algorithm specific parameters.

The first one is definitely going to there, however we can name it to GHT.
Supplying all 4 parameters for GHT algorithm requires advance knowledge, for which we have to understand algorithm.

However for 2nd one, we have to supply default parameters, which might not suffice the problem. The user will need more control to optimally solve his thresholding problem.

If my understanding is correct, This algorithm is for advanced User, since this requires tuning of 4 parameters.

@sciunto
Copy link
Member

sciunto commented Mar 22, 2021

I vote for the first proposition, parameters must be adjustable. We have also other algorithms requiring some knowledge in scikit-image. We must do our best in the docstring to provide an intuition of the behavior of each parameter (with a formula or with typical effects).

@divyank0
Copy link
Contributor

I have a created a pull request for this. do have a look.

one suggestion made by mkcor is to use default Parameter values. It might be a good idea, what does everyone think about it?

As to what those values could be? We could set values of nu, tau, omega, and kappa corresponding to Otsu's method.
Hence by default generalized histogram thresholding will work as Otsu's method.

@jni
Copy link
Member Author

jni commented Apr 22, 2021

The signature should take an image or a histogram, where the histogram can be either just the set of frequencies or the bin centres and the frequencies. See the code for Otsu's thresholding for details. The idea is that you can provide the image (as all thresholding methods do), or, if you have a precomputed histogram, you can provide the histogram, which is more efficient.

The parameters should all be accessible and yes, defaulting to Otsu's is probably the most sensible default.

immortal3 added a commit to immortal3/scikit-image that referenced this issue Aug 3, 2021
@scikit-image scikit-image locked and limited conversation to collaborators Oct 18, 2021
@grlee77 grlee77 reopened this Feb 20, 2022
@scikit-image scikit-image unlocked this conversation Feb 20, 2022
stefanv pushed a commit to immortal3/scikit-image that referenced this issue Apr 5, 2023
jarrodmillman pushed a commit that referenced this issue Apr 7, 2023
* Added cropping for image (ndarray) issue: #5189

* pep8 fixes

* added output in fn docstring

* auto pep8 fixes

* fixes testcases

* suggested fixes

* added copy flag and change function name to bounding_box_crop

* suggest change; axes name; slices use and valueerror test

* DOC: update bounding_box_crop docstring

* TST: use new-style random generator in test_cropy.py

* Rename crop.py to avoid name clash with the skimage.utils.crop function

add bounding_box_crop to skimage/utils/__init__.py

* fix circular import

* fix doctest

* Apply suggestions from code review

Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>

* Refactor bounding_box_crop to slice_along_axes

* Fix tests

* Fix linting

* Fix docstring

* Allow implicit axes; allow negative slicing

* Fix doctest

---------

Co-authored-by: Gregory Lee <grlee77@gmail.com>
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants