18 #ifndef itkImageToImageMetric_h
19 #define itkImageToImageMetric_h
53 template <
typename TFixedImage,
typename TMovingImage>
83 static constexpr
unsigned int MovingImageDimension = TMovingImage::ImageDimension;
84 static constexpr
unsigned int FixedImageDimension = TFixedImage::ImageDimension;
130 using typename Superclass::MeasureType;
133 using typename Superclass::DerivativeType;
136 using typename Superclass::ParametersType;
164 return this->GetNumberOfPixelsCounted();
167 itkGetConstReferenceMacro(NumberOfPixelsCounted,
SizeValueType);
171 SetFixedImageRegion(
const FixedImageRegionType reg);
174 itkGetConstReferenceMacro(FixedImageRegion, FixedImageRegionType);
177 #ifndef ITK_FUTURE_LEGACY_REMOVE
179 SetMovingImageMask(MovingImageMaskType *
const arg)
181 const auto *
const constArg = arg;
183 this->SetMovingImageMask(constArg);
186 itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
187 itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
191 #ifndef ITK_FUTURE_LEGACY_REMOVE
193 SetFixedImageMask(FixedImageMaskType *
const arg)
195 const auto *
const constArg = arg;
197 this->SetFixedImageMask(constArg);
200 itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
201 itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
207 SetFixedImageIndexes(
const FixedImageIndexContainer & indexes);
210 SetUseFixedImageIndexes(
bool useIndexes);
212 itkGetConstReferenceMacro(UseFixedImageIndexes,
bool);
217 itkGetConstReferenceMacro(NumberOfWorkUnits,
ThreadIdType);
221 itkSetMacro(ComputeGradient,
bool);
222 itkGetConstReferenceMacro(ComputeGradient,
bool);
223 itkBooleanMacro(ComputeGradient);
231 itkGetModifiableObjectMacro(GradientImage, GradientImageType);
235 SetTransformParameters(
const ParametersType & parameters)
const;
241 return m_Transform->GetNumberOfParameters();
250 MultiThreadingInitialize();
258 itkGetConstReferenceMacro(NumberOfFixedImageSamples,
SizeValueType);
266 this->SetNumberOfFixedImageSamples(num);
272 return this->GetNumberOfFixedImageSamples();
278 SetFixedImageSamplesIntensityThreshold(
const FixedImagePixelType & thresh);
280 itkGetConstReferenceMacro(FixedImageSamplesIntensityThreshold, FixedImagePixelType);
283 SetUseFixedImageSamplesIntensityThreshold(
bool useThresh);
285 itkGetConstReferenceMacro(UseFixedImageSamplesIntensityThreshold,
bool);
291 SetUseAllPixels(
bool useAllPixels);
296 this->SetUseAllPixels(
true);
302 this->SetUseAllPixels(
false);
305 itkGetConstReferenceMacro(UseAllPixels,
bool);
312 SetUseSequentialSampling(
bool useSequential);
314 itkGetConstReferenceMacro(UseSequentialSampling,
bool);
328 ReinitializeSeed(
int seed);
347 itkSetMacro(UseCachingOfBSplineWeights,
bool);
348 itkGetConstReferenceMacro(UseCachingOfBSplineWeights,
bool);
349 itkBooleanMacro(UseCachingOfBSplineWeights);
358 return m_ThreaderTransform.get();
367 PrintSelf(std::ostream & os,
Indent indent)
const override;
386 friend inline std::ostream &
390 os <<
"value: " << val.
value << std::endl;
391 os <<
"valueIndex: " << val.
valueIndex << std::endl;
402 bool m_UseFixedImageIndexes{
false };
405 bool m_UseFixedImageSamplesIntensityThreshold{
false };
452 bool m_ComputeGradient{
true };
460 bool m_UseAllPixels{
false };
461 bool m_UseSequentialSampling{
false };
463 bool m_ReseedIterator{
false };
465 mutable int m_RandomSeed{};
473 #ifndef ITK_FUTURE_LEGACY_REMOVE
477 bool m_TransformIsBSpline{
false };
484 static constexpr
unsigned int DeformationSplineOrder = 3;
522 bool m_UseCachingOfBSplineWeights{
true };
531 PreComputeTransformValues();
538 TransformPoint(
unsigned int sampleNumber,
541 double & movingImageValue,
549 TransformPointWithDerivatives(
unsigned int sampleNumber,
552 double & movingImageValue,
556 #ifndef ITK_FUTURE_LEGACY_REMOVE
560 bool m_InterpolatorIsBSpline{
false };
573 ComputeImageDerivatives(
const MovingImagePointType & mappedPoint,
574 ImageDerivativesType & gradient,
593 : m_ConstMetricPointer{ i2i_metricPointer }
598 return m_ConstMetricPointer;
617 : m_WorkUnitInfo(static_cast<const typename
MultiThreaderType::WorkUnitInfo *>(workunitInfoAsVoid))
622 return m_WorkUnitInfo->WorkUnitID;
627 return (static_cast<ConstantPointerWrapper *>(m_WorkUnitInfo->UserData))->GetConstMetricPointer();
638 bool m_WithinThreadPreProcess{
false };
639 bool m_WithinThreadPostProcess{
false };
642 GetValueMultiThreadedInitiate()
const;
645 GetValueMultiThreadedPostProcessInitiate()
const;
649 GetValueMultiThreaded(
void * workunitInfoAsVoid);
653 GetValueMultiThreadedPostProcess(
void * workunitInfoAsVoid);
667 double itkNotUsed(movingImageValue))
const
677 GetValueAndDerivativeMultiThreadedInitiate()
const;
680 GetValueAndDerivativeMultiThreadedPostProcessInitiate()
const;
683 GetValueAndDerivativeMultiThreaded(
void * workunitInfoAsVoid);
686 GetValueAndDerivativeMultiThreadedPostProcess(
void * workunitInfoAsVoid);
689 GetValueAndDerivativeThread(
ThreadIdType threadId)
const;
698 double itkNotUsed(movingImageValue),
713 SynchronizeTransforms()
const;
720 #ifndef ITK_MANUAL_INSTANTIATION
721 # include "itkImageToImageMetric.hxx"