ITK  6.0.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
*
* https://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()
{
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>;
auto caster = CasterType::New();
caster->SetInput(random->GetOutput());
caster->Update();
auto 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:53
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:88
New
static Pointer New()
itkImageToListSampleAdaptor.h
itk::RandomImageSource::New
static Pointer New()
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86