Bug in AutoThresholder / Minimum algorithm?
See original GitHub issueHi, I was looking into the AutoThresholder.Minimum method code, and I’ve noticed something that does not make sense, starting at the line 635:
double [] tHisto = iHisto;
while (!bimodalTest(iHisto) ) {
//smooth with a 3 point running mean filter
for (int i=1; i<255; i++)
tHisto[i]= (iHisto[i-1] + iHisto[i] +iHisto[i+1])/3;
tHisto[0] = (iHisto[0]+iHisto[1])/3; //0 outside
tHisto[255] = (iHisto[254]+iHisto[255])/3; //0 outside
iHisto = tHisto;
- First the line
double [] tHisto = iHisto;
is just a pointer affectation, not a copy. And then in the loop, we have the oppositeiHisto = tHisto;
. This pointer affectation followed by the opposite affectation does not have any sense. - Second, a smoothing is performed into the while loop. But the result in put into tHisto (for example
tHisto[i]= (iHisto[i-1] + iHisto[i] +iHisto[i+1])/3;
), but we’ve seen before thatdouble [] tHisto = iHisto;
. So the result is in fact put directly into the original array. When doing a smoothing, the result has to be stored into a separated array.
I think that a bug and it comes from a misunderstanding of the MatLab code. I guess that MatLab duplicates the code when doing an affectation like in the first line.
Am I wrong?
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (3 by maintainers)
Top Results From Across the Web
Bug 938 – Bug in the Intermodes algorithm of threshold - Fiji.sc
Hi, just a quick update. The Intermodes threshold method 'fails' in the 16bit image because the histogram is not bimodal. The value of...
Read more >Auto Threshold - ImageJ Wiki
This plugin binarises 8 and 16-bit images using various global (histogram-derived) thresholding methods. The segmented phase is always shown as white (255).
Read more >Bug in the Intermodes algorithm of threshold
However, the Intermodes algorithm in the plugin "Auto Thresholder" is correct. We attached you a minimal macro that reproduces this bug: ...
Read more >Unable to set threshold on Fiji - Usage & Issues
Hello! I am new to Fiji, and I am following a protocol where I am supposed to adjust the threshold of my TIF...
Read more >Possible wrong Otsu (auto) threshold value for binarisation
Submitted by Vincent Link to original bug (#679622) Description... ... Gimp use the Otsu method to compute binarization threshold.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@FiReTiTi I remember it now, @imagejan mentioned it recently: Open a pull request. https://help.github.com/articles/creating-a-pull-request/ Go to the Pull request tab and create a new one.
All three code location have been fixed: ImageJ1: https://github.com/imagej/imagej1/commit/031cbd239c89d5acb9038db86f3d1953a9604048 Fiji: https://github.com/fiji/Auto_Threshold/pull/6 ImageJ-Ops: https://github.com/imagej/imagej-ops/pull/423
Closing this now.