[Insight-users] Error using itk::statistics::Histogram GetMins()
Function
Matthias Keil
Matthias.Keil at igd.fraunhofer.de
Tue May 10 09:58:55 EDT 2005
Dear ITK users,
I am facing a problem using the GetMins() function of the Histogram
class. I am trying to get the bins minimum and maximum values. I am
getting the following compiler error calling this function.
D:\ITK\InsightToolkit-2.0.1\Code\Numerics\Statistics\itkHistogram.h(213)
: error C2440: 'return' : cannot convert from 'const class
std::vector<class std::vector<double,class std::allocator<double>
>,class std::allocator<class std::vector<double,class
std::allocator<double> > > >' to 'class std::vector<class
std::vector<double,class std::allocator<double> >,class
std::allocator<class std::vector<double,class std::allocator<double> > >
> &'
Conversion loses qualifiers
D:\ITK\InsightToolkit-2.0.1\Code\Numerics\Statistics\itkHistogram.h(213)
: while compiling class-template member function 'class
std::vector<class std::vector<double,class std::allocator<double>
>,class std::allocator<class std::vector<double,class
std::allocator<double> > > > &__thiscall
itk::Statistics::Histogram<double,2,class
itk::Statistics::DenseFrequencyContainer<float> >::GetMaxs(void) const'
I am getting the same error message when calling GetMaxs() function.
Here's a code snippet from my program:
// the necessary typedefs
typedef typename TInputImage::PixelType PixelType;
typedef itk::FixedArray< PixelType, 2 > MeasurementVectorType;
typedef itk::Image< MeasurementVectorType, 3 > ArrayImageType;
typedef itk::Statistics::ImageToHistogramGenerator<ArrayImageType>
Histogram2DGeneratorType;
typedef Histogram2DGeneratorType::HistogramType Histogram2DType;
....
// here I am using my own ImageToImageFilter
(m_pHistogram2DGeneratorFilter) for being able to put the histogram
computation into a mini pipeline
// the GetHistogramOutput() function returns an
itk::Statistics::ImageToHistogramGenerator<TInputImage>::HistogramType::ConstPointer,
where TInputImage is of ArrayImageType
Histogram2DType::ConstPointer histo =
m_pHistogram2DGeneratorFilter->GetHistogramOutput();
// here the program crashes with the mentioned error
Histogram2DType::BinMinContainerType minima = histo->GetMins();
I have already experimented a bit starting at the histogram.h file where
the GetMins() function is declared inline as follows:
/** Method to get the minimum vector */
BinMinContainerType& GetMins() const
{ return m_Min ; }
If I am deleting the & sign, i.e. not returning a reference but a const
copy of the m_Min member variable my program compiles and I seem to get
the values returned. But I don't want to change the code of ITK because
I think that it should also work returning a reference to this member
variable.
Is anybody facing the same problem or has already solved it? Has anybody
already used this function and it did work? Maybe you could tell me what
I am doing wrong.
I hope to hear from you, yours truly Matthias Keil
More information about the Insight-users
mailing list