Loading...
Searching...
No Matches
itkImageGridSampler.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* 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.
*
*=========================================================================*/
#ifndef itkImageGridSampler_h
#define itkImageGridSampler_h
#include "itkImageSamplerBase.h"
#include "elxMaskHasSameImageDomain.h"
namespace itk
{
template <class TInputImage>
class ITK_TEMPLATE_EXPORT ImageGridSampler : public ImageSamplerBase<TInputImage>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(ImageGridSampler);
using Self = ImageGridSampler;
using Superclass = ImageSamplerBase<TInputImage>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(ImageGridSampler, ImageSamplerBase);
using typename Superclass::DataObjectPointer;
using typename Superclass::OutputVectorContainerType;
using typename Superclass::OutputVectorContainerPointer;
using typename Superclass::InputImageType;
using typename Superclass::InputImagePointer;
using typename Superclass::InputImageConstPointer;
using typename Superclass::InputImageRegionType;
using typename Superclass::InputImagePixelType;
using typename Superclass::ImageSampleType;
using typename Superclass::ImageSampleContainerType;
using typename Superclass::ImageSampleContainerPointer;
// Clang/macos-12/Xcode_14.2 does not like `using typename Superclass::MaskType`, saying "error: 'MaskType' is not a
// class, namespace, or enumeration"
using MaskType = typename Superclass::MaskType;
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
using typename Superclass::InputImageIndexType;
// using typename Superclass::InputImageSpacingType;
using typename Superclass::InputImagePointType;
using SampleGridSpacingType = typename InputImageType::OffsetType;
using SampleGridSpacingValueType = typename SampleGridSpacingType::OffsetValueType;
using SampleGridSizeType = typename InputImageType::SizeType;
using SampleGridIndexType = InputImageIndexType;
using InputImageSizeType = typename InputImageType::SizeType;
void
SetSampleGridSpacing(const SampleGridSpacingType & arg);
itkGetConstReferenceMacro(SampleGridSpacing, SampleGridSpacingType);
void
SetNumberOfSamples(unsigned long nrofsamples) override;
bool
SelectNewSamplesOnUpdate() override
{
return false;
}
bool
SelectingNewSamplesOnUpdateSupported() const override
{
return false;
}
protected:
ImageGridSampler() = default;
~ImageGridSampler() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;
void
GenerateData() override;
private:
struct WorkUnit
{
const SampleGridIndexType GridIndex{};
const SampleGridSizeType GridSize{};
// Should point to the first sample for this specific work unit.
ImageSampleType * const Samples{};
// The number of samples retrieved by this work unit. Only used when a mask is specified.
size_t NumberOfSamples{};
};
struct UserData
{
ITK_DISALLOW_COPY_AND_MOVE(UserData);
const InputImageType & InputImage;
const MaskType * const Mask{};
const SampleGridSpacingType GridSpacing{};
std::vector<WorkUnit> WorkUnits{};
};
template <elastix::MaskCondition VMaskCondition>
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
ThreaderCallback(void * arg);
template <unsigned int VIndex>
static unsigned int
GetGridSizeValue(const SampleGridSizeType & gridSize)
{
if constexpr (VIndex < InputImageDimension)
{
return gridSize[VIndex];
}
else
{
return 1;
}
}
template <unsigned int VIndex>
static void
JumpToNextGridPosition(SampleGridIndexType & index,
const SampleGridIndexType & gridIndex,
const SampleGridSpacingType & gridSpacing)
{
static_assert(VIndex > 0);
if constexpr (VIndex < InputImageDimension)
{
index[VIndex - 1] = gridIndex[VIndex - 1];
index[VIndex] += gridSpacing[VIndex];
}
}
static std::pair<SampleGridIndexType, SampleGridSizeType>
DetermineGridIndexAndSize(const InputImageRegionType & croppedInputImageRegion,
const SampleGridSpacingType & gridSpacing);
static std::vector<WorkUnit>
GenerateWorkUnits(const ThreadIdType numberOfWorkUnits,
const InputImageRegionType & croppedInputImageRegion,
const SampleGridIndexType gridIndex,
const SampleGridSpacingType gridSpacing,
std::vector<ImageSampleType> & samples);
static void
SingleThreadedGenerateData(const TInputImage & inputImage,
const MaskType * const mask,
const InputImageRegionType & croppedInputImageRegion,
const SampleGridSpacingType & gridSpacing,
std::vector<ImageSampleType> & samples);
static void
MultiThreadedGenerateData(MultiThreaderBase & multiThreader,
const ThreadIdType numberOfWorkUnits,
const TInputImage & inputImage,
const MaskType * const mask,
const InputImageRegionType & croppedInputImageRegion,
const SampleGridSpacingType & gridSpacing,
std::vector<ImageSampleType> & samples);
template <elastix::MaskCondition VMaskCondition>
static void
GenerateDataForWorkUnit(WorkUnit &, const InputImageType &, const MaskType *, const SampleGridSpacingType &);
SampleGridSpacingType m_SampleGridSpacing{ itk::MakeFilled<SampleGridSpacingType>(1) };
unsigned long m_RequestedNumberOfSamples{ 0 };
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "itkImageGridSampler.hxx"
#endif
#endif // end #ifndef itkImageGridSampler_h
itk::ImageGridSampler::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkImageGridSampler.h:54
itk::ImageGridSampler::MultiThreadedGenerateData
static void MultiThreadedGenerateData(MultiThreaderBase &multiThreader, const ThreadIdType numberOfWorkUnits, const TInputImage &inputImage, const MaskType *const mask, const InputImageRegionType &croppedInputImageRegion, const SampleGridSpacingType &gridSpacing, std::vector< ImageSampleType > &samples)
itk::ImageGridSampler::MaskType
typename Superclass::MaskType MaskType
Definition itkImageGridSampler.h:77
itk::ImageGridSampler::GenerateDataForWorkUnit
static void GenerateDataForWorkUnit(WorkUnit &, const InputImageType &, const MaskType *, const SampleGridSpacingType &)
itk::ImageGridSampler::itkStaticConstMacro
itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension)
itk::ImageGridSampler::~ImageGridSampler
~ImageGridSampler() override=default
itk::ImageGridSampler::ImageSampleType
ImageSample< InputImageType > ImageSampleType
Definition itkImageSamplerBase.h:76
itk::ImageGridSampler::SampleGridSpacingType
typename InputImageType::OffsetType SampleGridSpacingType
Definition itkImageGridSampler.h:88
itk::ImageGridSampler::SelectNewSamplesOnUpdate
bool SelectNewSamplesOnUpdate() override
Definition itkImageGridSampler.h:125
itk::ImageGridSampler::GetGridSizeValue
static unsigned int GetGridSizeValue(const SampleGridSizeType &gridSize)
Definition itkImageGridSampler.h:184
itk::ImageGridSampler::Self
ImageGridSampler Self
Definition itkImageGridSampler.h:51
itk::ImageGridSampler< FixedImageType >::m_SampleGridSpacing
SampleGridSpacingType m_SampleGridSpacing
Definition itkImageGridSampler.h:247
itk::ImageGridSampler::SampleGridSizeType
typename InputImageType::SizeType SampleGridSizeType
Definition itkImageGridSampler.h:90
itk::ImageGridSampler::GenerateWorkUnits
static std::vector< WorkUnit > GenerateWorkUnits(const ThreadIdType numberOfWorkUnits, const InputImageRegionType &croppedInputImageRegion, const SampleGridIndexType gridIndex, const SampleGridSpacingType gridSpacing, std::vector< ImageSampleType > &samples)
itk::ImageGridSampler::SingleThreadedGenerateData
static void SingleThreadedGenerateData(const TInputImage &inputImage, const MaskType *const mask, const InputImageRegionType &croppedInputImageRegion, const SampleGridSpacingType &gridSpacing, std::vector< ImageSampleType > &samples)
itk::ImageGridSampler::DetermineGridIndexAndSize
static std::pair< SampleGridIndexType, SampleGridSizeType > DetermineGridIndexAndSize(const InputImageRegionType &croppedInputImageRegion, const SampleGridSpacingType &gridSpacing)
itk::ImageGridSampler::SelectingNewSamplesOnUpdateSupported
bool SelectingNewSamplesOnUpdateSupported() const override
Definition itkImageGridSampler.h:133
itk::ImageGridSampler::GenerateData
void GenerateData() override
itk::ImageGridSampler::SetSampleGridSpacing
void SetSampleGridSpacing(const SampleGridSpacingType &arg)
itk::ImageGridSampler::Superclass
ImageSamplerBase< TInputImage > Superclass
Definition itkImageGridSampler.h:52
itk::ImageGridSampler::ImageGridSampler
ImageGridSampler()=default
itk::ImageGridSampler::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::ImageGridSampler::InputImageType
TInputImage InputImageType
Definition itkImageSamplerBase.h:66
itk::ImageGridSampler::InputImageIndexType
typename InputImageType::IndexType InputImageIndexType
Definition itkImageSamplerBase.h:80
itk::ImageGridSampler< FixedImageType >::m_RequestedNumberOfSamples
unsigned long m_RequestedNumberOfSamples
Definition itkImageGridSampler.h:250
itk::ImageGridSampler::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(ImageGridSampler)
itk::ImageGridSampler::JumpToNextGridPosition
static void JumpToNextGridPosition(SampleGridIndexType &index, const SampleGridIndexType &gridIndex, const SampleGridSpacingType &gridSpacing)
Definition itkImageGridSampler.h:199
itk::ImageGridSampler::SampleGridIndexType
InputImageIndexType SampleGridIndexType
Definition itkImageGridSampler.h:91
itk::ImageGridSampler::InputImageSizeType
typename InputImageType::SizeType InputImageSizeType
Definition itkImageGridSampler.h:92
itk::ImageGridSampler< FixedImageType >::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
itk::ImageGridSampler::SampleGridSpacingValueType
typename SampleGridSpacingType::OffsetValueType SampleGridSpacingValueType
Definition itkImageGridSampler.h:89
itk::ImageGridSampler::ThreaderCallback
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION ThreaderCallback(void *arg)
itk::ImageGridSampler::Pointer
SmartPointer< Self > Pointer
Definition itkImageGridSampler.h:53
itk::ImageGridSampler::SetNumberOfSamples
void SetNumberOfSamples(unsigned long nrofsamples) override
itk::ImageSamplerBase< FixedImageType >::OutputVectorContainerPointer
typename OutputVectorContainerType::Pointer OutputVectorContainerPointer
itk::ImageSamplerBase< FixedImageType >::OutputVectorContainerType
VectorDataContainer< std::vcl_size_t, ImageSample< FixedImageType > > OutputVectorContainerType
itk::ImageSamplerBase< FixedImageType >::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition itkImageSamplerBase.h:68
itk::ImageSamplerBase< FixedImageType >::ImageSampleType
ImageSample< InputImageType > ImageSampleType
Definition itkImageSamplerBase.h:76
itk::ImageSamplerBase< FixedImageType >::ImageSampleContainerType
VectorDataContainer< std::vcl_size_t, ImageSampleType > ImageSampleContainerType
Definition itkImageSamplerBase.h:77
itk::ImageSamplerBase< FixedImageType >::InputImagePointType
typename InputImageType::PointType InputImagePointType
Definition itkImageSamplerBase.h:81
itk::ImageSamplerBase< FixedImageType >::InputImageType
FixedImageType InputImageType
Definition itkImageSamplerBase.h:66
itk::ImageSamplerBase< FixedImageType >::InputImageIndexType
typename InputImageType::IndexType InputImageIndexType
Definition itkImageSamplerBase.h:80
itk::ImageSamplerBase< FixedImageType >::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition itkImageSamplerBase.h:69
itk::ImageSamplerBase::ImageSamplerBase
ImageSamplerBase()
itk::ImageSamplerBase< FixedImageType >::ImageSampleContainerPointer
typename ImageSampleContainerType::Pointer ImageSampleContainerPointer
Definition itkImageSamplerBase.h:78
itk::ImageSamplerBase< FixedImageType >::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition itkImageSamplerBase.h:67
itk::ImageSamplerBase::MaskType
ImageMaskSpatialObject< Self::InputImageDimension > MaskType
Definition itkImageSamplerBase.h:84
itk::ImageSamplerBase< FixedImageType >::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition itkImageSamplerBase.h:70
elxMaskHasSameImageDomain.h
itkImageSamplerBase.h
itk
Definition itkAdvancedImageToImageMetric.h:43
itk::ImageGridSampler::UserData
Definition itkImageGridSampler.h:168
itk::ImageGridSampler::UserData::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(UserData)
itk::ImageGridSampler::UserData::Mask
const MaskType *const Mask
Definition itkImageGridSampler.h:172
itk::ImageGridSampler::UserData::InputImage
const InputImageType & InputImage
Definition itkImageGridSampler.h:171
itk::ImageGridSampler::UserData::WorkUnits
std::vector< WorkUnit > WorkUnits
Definition itkImageGridSampler.h:174
itk::ImageGridSampler::UserData::GridSpacing
const SampleGridSpacingType GridSpacing
Definition itkImageGridSampler.h:173
itk::ImageGridSampler::WorkUnit
Definition itkImageGridSampler.h:156
itk::ImageGridSampler::WorkUnit::GridSize
const SampleGridSizeType GridSize
Definition itkImageGridSampler.h:158
itk::ImageGridSampler::WorkUnit::GridIndex
const SampleGridIndexType GridIndex
Definition itkImageGridSampler.h:157
itk::ImageGridSampler::WorkUnit::NumberOfSamples
vcl_size_t NumberOfSamples
Definition itkImageGridSampler.h:164
itk::ImageGridSampler::WorkUnit::Samples
ImageSampleType *const Samples
Definition itkImageGridSampler.h:161

Generated on 1768596610 for elastix by 1.15.0 |