<div dir="ltr">Hi,<div style>I think the order was - I introduced new filters copied from ImageJ, then Gaetan started refactoring to use the histogram framework. We both did some work to make that correspond to old versions. I don't remember working on the MultipleThreshold version, but the code does look similar, so perhaps it was done somewhere along the way - will need to check the logs.</div>
<div style><br></div><div style>I'm pretty sure that Otsu was producing the same results that it used to - I didn't compare to other implementations. Thus, if the original Otsu was correct then the current one should be too, which would suggest that the MultipleThresholds version should probably change.</div>
<div style><br></div><div style>Not sure when I'll get a chance to look at this in detail.</div><div style><br></div><div style>I don't have a current email for Gaetan to CC for confirmation.</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Jul 1, 2013 at 11:02 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dirk,<br>
<br>
I believe Richard Beare did the refactoring of the thresholding framework an Insight Journal Article. He will likely know why it is this way better than anyone else.<br>
<br>
You also didn't say which implementation is correct.<br>
<br>
Brad<br>
<br>
<br>
On Jun 30, 2013, at 10:03 PM, "Padfield, Dirk R (GE Global Research)" <<a href="mailto:padfield@research.ge.com">padfield@research.ge.com</a>> wrote:<br>
<br>
> Hi ITK Developers,<br>
><br>
> I was just looking through the OtsuThresholdCalculator and OtsuMultipleThresholdsCalculator to see whether I could refactor them so that the Otsu inherits from the OtsuMultiple since the latter is a more general case of the former. Currently, the code for these two filters is totally different resulting in significant code duplication and a need to keep both filters in sync.<br>
><br>
> As a first step, I wrote a CMake test to check that the output of the OtsuMultiple with 1 threshold is the same as the output of the Otsu. Unfortunately, they are not! The two filters output thresholds that are different by 1 histogram bin! This can be a quite extreme difference when the numberOfHistogramBins is low, and it leads to different thresholds even when the numberOfHistogramBins is reasonably high (say 256). I tracked it down to this code in the Calculators:<br>
><br>
> The relevant code from Otsu:<br>
> const double tolerance = 0.00001;<br>
> if ( (varBetween - tolerance) > maxVarBetween )<br>
> {<br>
> maxVarBetween = varBetween;<br>
> maxBinNumber = j;<br>
> }<br>
> }<br>
> this->GetOutput()->Set( static_cast<OutputType>( histogram->GetMeasurement( maxBinNumber + 1, 0 ) ) );<br>
><br>
> The relevant code from MultipleOtsu:<br>
> if ( varBetween > maxVarBetween )<br>
> {<br>
> maxVarBetween = varBetween;<br>
> maxVarThresholdIndexes = thresholdIndexes;<br>
> }<br>
> }<br>
> for ( j = 0; j < m_NumberOfThresholds; j++ )<br>
> {<br>
> m_Output[j] = histogram->GetBinMax(0, maxVarThresholdIndexes[j]);<br>
> }<br>
><br>
> The difference is that the Otsu adds one to the computed threshold whereas the MultipleOtsu does not. This is problematic because users would expect them to give the same result.<br>
><br>
> My question is: how should we proceed? If we change one or the other, people's code that use the changed one will give slightly different answers. If we don't change them, the two filters will give different outputs for the same input, and it will not be possible to refactor them to share code.<br>
><br>
> What are your thoughts?<br>
><br>
> Thanks,<br>
> Dirk<br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
<br>
</blockquote></div><br></div>