0

I am currently working with the try_all_threshold function that comes with the skimage filters package (skimage.filters.try_all_threshold).

It applies 8 types of thresholding methods on an image and then plots these 8 generated thresholds next to each other. However, there are way more thresholding methods described in the skimage documentation, and I am currently trying to find a way of modifying the try_all_threshold function in a way that I could either add or exchange the thresholding methods that it usually applies, with alternative ones from the scikit environment.

For example: Instead of using the skimage.filters.threshold_li method, I would want to use the skimage.filters.threshold_multiotsu method in the try_all_threshold function. And ideally, I would want to also use more than 8 threshold methods at the same time to get a better overview, but I dont know if that is possible.

Does anyone have an idea on how to do that?

Thank you all very much for your help and a good day!

Phil
  • 29
  • 5

1 Answers1

1

The source code for the function is here:

https://github.com/scikit-image/scikit-image/blob/v0.19.0/skimage/filters/thresholding.py#L97-L154

And you can see that it calls a private _try_all function here:

https://github.com/scikit-image/scikit-image/blob/812e21e44129258d8637fbcf665e590556ea96d1/skimage/filters/thresholding.py#L35

try_all_threshold is too inflexible (this should be improved) for you to modify a call to that function to do what you like, but you can copy the code and modify either function to add your preferred thresholding methods. Note that multiotsu is fundamentally different because it returns multiple threshold values, so you can't do image > threshold_multiotsu(image); instead you have to do np.digitize(image, threshold_multiotsu(image)).

Juan
  • 5,433
  • 21
  • 23
  • Hi there! Thanks very much for your help on this question too. Coming back from christmas break now managed to implement the suggestions. Have a good day! – Phil Jan 11 '22 at 13:12