ITK  4.8.0
Insight Segmentation and Registration Toolkit
WikiExamples/Statistics/ImageToListSampleAdaptor.cxx
#include "itkImage.h"
int main(int, char *[])
{
typedef itk::Image<float,2> FloatImage2DType;
random->SetMin( 0.0 );
random->SetMax( 1000.0 );
typedef FloatImage2DType::SpacingValueType SpacingValueType;
typedef FloatImage2DType::PointValueType PointValueType;
SizeValueType size[2] = {20, 20};
random->SetSize( size );
SpacingValueType spacing[2] = {0.7, 2.1};
random->SetSpacing( spacing );
PointValueType origin[2] = {15, 400};
random->SetOrigin( origin );
typedef itk::FixedArray< float, 1 > MeasurementVectorType;
CasterType;
CasterType::Pointer caster = CasterType::New();
caster->SetInput( random->GetOutput() );
caster->Update();
SampleType::Pointer sample = SampleType::New();
sample->SetImage( caster->GetOutput() );
SampleType::Iterator iter = sample->Begin() ;
while( iter != sample->End() )
{
std::cout << iter.GetMeasurementVector() << std::endl ;
++iter;
}
return EXIT_SUCCESS;
}