[Insight-users] SetHistogramMin and SetHistogramMax
Mauro Maiorca
mauromaiorca at gmail.com
Wed Apr 6 13:02:45 EDT 2011
Hello itk users,
I'm trying to perform otsu thresholding on a CT image. In particular I
want to threshold within the range [minValue, maxValue] with itk
3.20.0
I'm unisng itk::Statistics::ScalarImageToHistogramGenerator and
itk::OtsuMultipleThresholdsCalculator.
Unfortunately, SetHistogramMin and SetHistogramMax don't seem to work
to me! In fact, if I comment those 2 lines out:
// scalarImageToHistogramGenerator->SetHistogramMin( minValue );
// scalarImageToHistogramGenerator->SetHistogramMax( maxValue );
I have the same result of when I leave those lines uncommented. I'm
actually using some code of few years ago (it was working before, I
just recompiled it today, not sure which itk version I was using at
that time).
The code I'm using is quite trivial (please, let me know if you want
me to provide more details)! Am I doing something wrong? Is it a bug?
Is this the correct mailing list to post this kind of questions? Any
hint?
here the chunk of code:
typedef itk::Statistics::ScalarImageToHistogramGenerator<
InputImageType > ScalarImageToHistogramGeneratorType;
typedef ScalarImageToHistogramGeneratorType::HistogramType HistogramType;
typedef itk::OtsuMultipleThresholdsCalculator< HistogramType >
CalculatorType;
ScalarImageToHistogramGeneratorType::Pointer
scalarImageToHistogramGenerator =
ScalarImageToHistogramGeneratorType::New();
CalculatorType::Pointer calculator = CalculatorType::New();
scalarImageToHistogramGenerator->SetNumberOfBins( 128 );
scalarImageToHistogramGenerator->SetMarginalScale( 5.0 );
scalarImageToHistogramGenerator->SetInput( inputImage );
// scalarImageToHistogramGenerator->SetHistogramMin( minValue ); //
<------- huh????
// scalarImageToHistogramGenerator->SetHistogramMax( maxValue );//
<--------huh????
scalarImageToHistogramGenerator->Compute();
const HistogramType * histogramLow =
scalarImageToHistogramGenerator-> GetOutput();
calculator->SetNumberOfThresholds( 3 );
calculator->SetInputHistogram( histogramLow );
calculator->Update();
CalculatorType::OutputType::const_iterator itNumLow =
(calculator->GetOutput()).begin();
HuMinimum = (int)static_cast<itk::NumericTraits<CalculatorType::MeasurementType>::PrintType>(*itNumLow);
--
Regards,
Mauro
More information about the Insight-users
mailing list