ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/Statistics/ImageToListSampleAdaptor.cxx
#include "itkImage.h"
int main(int, char *[])
{
using FloatImage2DType = itk::Image<float,2>;
random->SetMin( 0.0 );
random->SetMax( 1000.0 );
using SpacingValueType = FloatImage2DType::SpacingValueType;
using PointValueType = FloatImage2DType::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 );
using MeasurementVectorType = itk::FixedArray< float, 1 >;
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;
}