[Insight-users] Histogram creation...

Luis Ibanez luis.ibanez at kitware.com
Fri, 16 Jan 2004 11:28:27 -0500


Hi Jean-Philippe


It is not clear from your code what the
type of the variable HistogramGenerator
is.

 From the typedefs it may seem that is
a ListSampleToHistogramFilter but from
the name it insinuates to be a
ListSampleToHistogramGenerator.

Could you please post the variable
declarations ?

or even better,

a complete piece of code that we could
compille and run...to try to reproduce
the error that you find.



Thanks,


   Luis


------------------------
Jean-Philippe Guyon wrote:

> Hello,
> 
> I am trying to create a histogram that contains values of all the 
> pixels within a volume extracted using the GeodesicActiveContour 
> approach provided by ITK.
> Basically, the result of the segmentation algorithm is used as a mask 
> for the histogram generation.
> I am using the code below and I get the following exception when I call 
> the final Update():
> 
> itk::ERROR: Histogram(0581A178): One of the measurement components is 
> below the minimum
> 
> I find it surprising to get that error message since the image processed 
> contains only positive values.
> Any idea why this happens ???
> 
> Jean-Philippe
> 
> ---------------------------------------------------------------------------------------------------------------
> 
> typedef typename itk::Vector<typename 
> InputType::PixelType,1>                              VectorType;
> typedef typename itk::Statistics::ListSample<VectorType 
>  >                                          HistogramSampleType;
> typedef typename 
> HistogramSampleType::Pointer                                                          
> HistogramSamplePointer;
> typedef typename itk::Statistics::Histogram<typename 
> MaskType::PixelType,1 >    HistogramType;
> typedef typename 
> HistogramType::Pointer                                                                       
> HistogramPointer;
> typedef typename 
> HistogramType::SizeType                                                                   HistogramSizeType;
> typedef itk::Statistics::ListSampleToHistogramFilter< 
> HistogramSampleType, HistogramType > HistogramFilterType;
> typedef typename 
> HistogramFilterType::Pointer                                                              
> HistogramFilterPointer;
> 
> //....
> // Definition of iterators, etc....
> //....
> 
> HistogramType::SizeType size;
> HistogramType::MeasurementVectorType min;
> HistogramType::MeasurementVectorType max;
> 
> size.Fill(25);
> min.Fill(0);
> max.Fill(999999);
> 
> this->m_Histogram = HistogramType::New();
> this->m_Histogram->Initialize(size,min,max);
> 
> this->m_HistogramSample = HistogramSampleType::New();
> 
> this->m_HistogramGenerator = HistogramFilterType::New();
> this->m_HistogramGenerator->SetListSample(this->m_HistogramSample);
> this->m_HistogramGenerator->SetHistogram(this->m_Histogram);
> 
> while(!maskIt.IsAtEnd())
> {
>     if(maskIt.Value())
>     {
>     this->m_HistogramSample->PushBack(inputIt.Value());
>     }
>     ++maskIt;
>     ++inputIt;
> }
> 
> this->m_HistogramGenerator->Update();
> 
>