ITK  5.2.0
Insight Toolkit
SphinxExamples/src/Numerics/Statistics/CreateListOfSamplesFromImageWithoutDuplication/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#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>;
using ArrayImageType = itk::Image<MeasurementVectorType, 2>;
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;
}
itk::Statistics::ImageToListSampleAdaptor
This class provides ListSample interface to ITK Image.
Definition: itkImageToListSampleAdaptor.h:54
itkComposeImageFilter.h
itkImage.h
itk::SmartPointer< Self >
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:52
itkRandomImageSource.h
itk::ComposeImageFilter
ComposeImageFilter combine several scalar images into a multicomponent image.
Definition: itkComposeImageFilter.h:62
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itkImageToListSampleAdaptor.h
itk::RandomImageSource::New
static Pointer New()
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83