int main()
{
typedef int MeasurementType;
const unsigned int MeasurementVectorLength = 2;
MeasurementVectorType;
ListSampleType::Pointer listSample = ListSampleType::New();
listSample->SetMeasurementVectorSize( MeasurementVectorLength );
MeasurementVectorType mv;
for ( unsigned int i = 1; i < 6; i++ )
{
for ( unsigned int j = 0; j < 2; j++ )
{
mv[j] = ( MeasurementType ) i;
}
for ( unsigned int j = 0; j < i; j++ )
{
listSample->PushBack(mv);
}
}
typedef float HistogramMeasurementType;
const unsigned int numberOfComponents = 2;
HistogramType;
HistogramType::SizeType size( numberOfComponents );
size.Fill(5);
HistogramType::MeasurementVectorType lowerBound( numberOfComponents );
HistogramType::MeasurementVectorType upperBound( numberOfComponents );
lowerBound[0] = 0.5;
lowerBound[1] = 0.5;
upperBound[0] = 5.5;
upperBound[1] = 5.5;
HistogramType > FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput( listSample );
filter->SetHistogramSize( size );
filter->SetHistogramBinMinimum( lowerBound );
filter->SetHistogramBinMaximum( upperBound );
filter->Update();
const HistogramType* histogram = filter->GetOutput();
HistogramType::ConstIterator iter = histogram->Begin();
while ( iter != histogram->End() )
{
std::cout << "Measurement vectors = " << iter.GetMeasurementVector()
<< " frequency = " << iter.GetFrequency() << std::endl;
++iter;
}
std::cout << "Size = " << histogram->Size() << std::endl;
std::cout << "Total frequency = "
<< histogram->GetTotalFrequency() << std::endl;
return 0;
}