manuelaguadomtz / pythreshold

PyThreshold is a python package featuring Numpy/Scipy implementations of state-of-the-art image thresholding algorithms.
MIT License
58 stars 17 forks source link

Multi-Moments threshold #2

Open pedrogalher opened 3 years ago

pedrogalher commented 3 years ago

Hi,

Thank you very much for your implementations. I have been working in the implementation of the Moments threshold developed by Tsai for the tri-level case. I have already written the code but I don't trust very much my implementation since some of the resulting parameters are really out of the order of magnitude of what Tsai explains in his paper. Could I send you my adaptation of this threshold and explore ways to include it in the pythreshold library?

Pedro

manuelaguadomtz commented 3 years ago

Hi Pedro!

Sorry for the delayed answer. You are welcome to send me your implementation of the algorithm, or even better, to submit a pull request. Currently, I don't have much time available, but I will be glad to review your code as soon as possible.

Manuel

pedrogalher commented 3 years ago

Hi Manuel,

Thanks for your answer. I'll submit the pull request asap.

Thanks :) Pedro

pedrogalher commented 3 years ago

@manuelaguadomtz Hi Manuel,

I have just added the pull request for the threshold based on the moments preservation principle. I did it for the bimodal and trimodal case since the method developed by Tsai is based on pretty big formulas depending especifically in the number of phases you have in your image, so it is not easily escalable to more than 3 phases. Sorry it took me so much time. I have been pretty busy with my PhD project and could't find the right time to do it.

SInce I work with CT data (stack of 2D images), my code is prepared to read the 2D images from a folder containing the entire stack and convert it to a 3D numpy array. From there, I guess my procedure is the same as you have done in your code for other thresholds. Feel free to adapt the code so that it is consistent with your scripts (I think your input is directly either a numpy array or its histogram).