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

Bernsen thresholding #84

Closed
fkim1223 opened this issue Jan 10, 2017 · 3 comments
Closed

Bernsen thresholding #84

fkim1223 opened this issue Jan 10, 2017 · 3 comments

Comments

@fkim1223
Copy link

Hi,
I recently discovered this python program to try bernsen's thresholding method. I liked the option to change gthresh value. I gave it a try and I was getting a different result from bernsen's method implemented in imagej though. After looking at the code, it appears that there may be an error on line 258: fmean = fmax/.2 + fmin/.2. I think the values should be divided by 2 not 0.2. Is it possible to check and recompile the code if it is an error? Thank you.

@luispedro
Copy link
Owner

That's a good catch!

@fkim1223
Copy link
Author

Hi Thank you for checking and making the change. I had tried modifying the code myself, and I think the line 259 may also have to be changed to something like np.choose(fptp < contrast_threshold,(f >= fmean, f >= gthresh)). After that, I'm getting a very similar result to that of imagej. I think the difference may be related to the way structural element is defined in both programs. I'll have to compare this later. I'm new to python, and it took me awhile to understand numpy choose command. Please check if my proposed modification makes sense. Would this program process 16 bit image as well?

@luispedro
Copy link
Owner

Yes, 16 bits should not be a problem.

There may indeed be a difference in whether the comparison to the threshold is performed as a > or a >=. I would actually like to compare with the original publication, but I cannot seem to get it.

luispedro added a commit that referenced this issue Oct 14, 2021
The formula contained an important typo.

close #84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants