question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in AutoThresholder / Minimum algorithm?

See original GitHub issue

Hi, 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 opposite iHisto = 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 that double [] 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:closed
  • Created 7 years ago
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
landinigcommented, Jul 14, 2016

@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.

0reactions
imagejancommented, Jul 15, 2016
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found