[Insight-developers] correct use of ImageToHistogramFilter

Richard Beare richard.beare at gmail.com
Wed May 5 02:04:07 EDT 2010


Hello,

I'm struggling getting this filter to work under ITK 3.16, and I
suspect I'm missing something in the histogram terminology or getting
mixed up in the decorator macros:

      typedef typename
itk::Statistics::ImageToHistogramFilter<OutImType> HistGenType;
      typedef typename HistGenType::HistogramType HistogramType;
      typename HistGenType::Pointer Hist = HistGenType::New();
      typename HistGenType::HistogramSizeType hsize;
      typename HistGenType::HistogramMeasurementVectorType hmeas;

      hsize.Fill(100);
      hmeas.Fill(0.1);
      Hist->SetInput(Rescaler->GetOutput());
      // one component histogram

      Hist->SetHistogramSize(hsize);

      typename HistGenType::HistogramMeasurementVectorType hmin, hmax;
      hmin.Fill(CmdLineObj.hmin);
      hmax.Fill(CmdLineObj.hmax);

      Hist->SetHistogramBinMinimum(hmin);
      Hist->SetHistogramBinMaximum(hmax);
      Hist->SetMarginalScale(0.1);
      Hist->Update();


I get the following error:

itk::ERROR: SampleToHistogramFilter(0x129ff2d0): Histogram number of
components: 0 doesn't match Measurement Vector Size: 1


if I change the call to

Hist->SetHistogramSize(100);

I get

terminate called after throwing an instance of 'itk::ExceptionObject'
  what():  /usr/local/hpcmedsw/ITK/ITK-3.16/include/InsightToolkit/Review/Statistics/itkSampleToHistogramFilter.txx:185:
itk::ERROR: SampleToHistogramFilter(0x1a5ba2d0): Histogram number of
components: 100 doesn't match Measurement Vector Size: 1


What am I doing wrong?


More information about the Insight-developers mailing list