go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedKappaStatisticImageToImageMetric.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright UMC Utrecht and contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkAdvancedKappaStatisticImageToImageMetric_h
19#define itkAdvancedKappaStatisticImageToImageMetric_h
20
22#include <vector>
23
24namespace itk
25{
26
55
56template <typename TFixedImage, typename TMovingImage>
58 : public AdvancedImageToImageMetric<TFixedImage, TMovingImage>
59{
60public:
62
66 using Pointer = SmartPointer<Self>;
67 using ConstPointer = SmartPointer<const Self>;
68
70 itkNewMacro(Self);
71
74
76 using typename Superclass::CoordinateRepresentationType;
77 using typename Superclass::MovingImageType;
78 using typename Superclass::MovingImagePixelType;
79 using typename Superclass::MovingImageConstPointer;
80 using typename Superclass::FixedImageType;
81 using typename Superclass::FixedImageConstPointer;
82 using typename Superclass::FixedImageRegionType;
83 using typename Superclass::TransformType;
84 using typename Superclass::TransformPointer;
85 using typename Superclass::InputPointType;
86 using typename Superclass::OutputPointType;
87 using typename Superclass::TransformJacobianType;
89 using typename Superclass::InterpolatorType;
90 using typename Superclass::InterpolatorPointer;
91 using typename Superclass::RealType;
92 using typename Superclass::GradientPixelType;
93 using typename Superclass::GradientImageType;
94 using typename Superclass::GradientImagePointer;
95 using typename Superclass::FixedImageMaskType;
99 using typename Superclass::MeasureType;
100 using typename Superclass::DerivativeType;
101 using typename Superclass::DerivativeValueType;
102 using typename Superclass::ParametersType;
103 using typename Superclass::FixedImagePixelType;
105 using typename Superclass::ImageSamplerType;
106 using typename Superclass::ImageSamplerPointer;
114 using typename Superclass::ThreadInfoType;
115
117 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
118
120 itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension);
121
123 MeasureType
124 GetValue(const ParametersType & parameters) const override;
125
127 void
128 GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
129
131 virtual void
132 GetValueAndDerivativeSingleThreaded(const ParametersType & parameters,
133 MeasureType & Value,
134 DerivativeType & Derivative) const;
135
136 void
137 GetValueAndDerivative(const ParametersType & parameters,
138 MeasureType & Value,
139 DerivativeType & Derivative) const override;
140
142 void
143 ComputeGradient() override;
144
146 itkSetMacro(ForegroundValue, RealType);
147 itkGetConstReferenceMacro(ForegroundValue, RealType);
148
153 itkSetMacro(UseForegroundValue, bool);
154
160 itkSetMacro(Complement, bool);
161 itkGetConstReferenceMacro(Complement, bool);
162 itkBooleanMacro(Complement);
163
165 itkSetMacro(Epsilon, RealType);
166 itkGetConstReferenceMacro(Epsilon, RealType);
167
168protected:
171
173 void
174 PrintSelf(std::ostream & os, Indent indent) const override;
175
177
179 using typename Superclass::FixedImageIndexType;
182 using typename Superclass::FixedImagePointType;
188
192 void
193 UpdateValueAndDerivativeTerms(const RealType fixedImageValue,
194 const RealType movingImageValue,
195 std::size_t & fixedForegroundArea,
196 std::size_t & movingForegroundArea,
197 std::size_t & intersection,
198 const DerivativeType & imageJacobian,
199 const NonZeroJacobianIndicesType & nzji,
200 DerivativeType & sum1,
201 DerivativeType & sum2) const;
202
207 void
209
211 void
212 ThreadedGetValueAndDerivative(ThreadIdType threadID) const override;
213
215 void
216 AfterThreadedGetValueAndDerivative(MeasureType & value, DerivativeType & derivative) const override;
217
219 static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION
221
222private:
223 bool m_UseForegroundValue{ true }; // for backwards compatibility
224 RealType m_ForegroundValue{ 1.0 };
225 RealType m_Epsilon{ 1e-3 };
226 bool m_Complement{ true };
227
229
241
243 {
245 SizeValueType st_AreaSum;
246 SizeValueType st_AreaIntersection;
247 DerivativeType st_DerivativeSum1;
248 DerivativeType st_DerivativeSum2;
249 };
250 itkPadStruct(ITK_CACHE_LINE_ALIGNMENT,
251 KappaGetValueAndDerivativePerThreadStruct,
252 PaddedKappaGetValueAndDerivativePerThreadStruct);
253 itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT,
254 PaddedKappaGetValueAndDerivativePerThreadStruct,
255 AlignedKappaGetValueAndDerivativePerThreadStruct);
256 mutable std::vector<AlignedKappaGetValueAndDerivativePerThreadStruct>
258};
259
260} // end namespace itk
261
262#ifndef ITK_MANUAL_INSTANTIATION
263# include "itkAdvancedKappaStatisticImageToImageMetric.hxx"
264#endif
265
266#endif // end #ifndef itkAdvancedKappaStatisticImageToImageMetric_h
typename TransformType::OutputPointType MovingImagePointType
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
BSplineInterpolateImageFunction< MovingImageType, CoordinateRepresentationType, double > BSplineInterpolatorType
typename MovingImageType::RegionType MovingImageRegionType
typename AdvancedTransformType::NonZeroJacobianIndicesType NonZeroJacobianIndicesType
FixedArray< double, Self::MovingImageDimension > MovingImageDerivativeScalesType
typename FixedImageType::PixelType FixedImagePixelType
typename DerivativeType::ValueType DerivativeValueType
typename FixedImageIndexType::IndexValueType FixedImageIndexValueType
typename MovingImageType::IndexType MovingImageIndexType
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename FixedImageType::IndexType FixedImageIndexType
SmartPointer< MovingImageMaskType > MovingImageMaskPointer
LimiterFunctionBase< RealType, FixedImageDimension > FixedImageLimiterType
ImageSamplerBase< FixedImageType > ImageSamplerType
MultiThreaderBase::WorkUnitInfo ThreadInfoType
typename BSplineInterpolatorType::CovariantVectorType MovingImageDerivativeType
LimiterFunctionBase< RealType, MovingImageDimension > MovingImageLimiterType
typename MovingImageLimiterType::OutputType MovingImageLimiterOutputType
typename TransformType::InputPointType FixedImagePointType
typename FixedImageLimiterType::OutputType FixedImageLimiterOutputType
SmartPointer< FixedImageMaskType > FixedImageMaskPointer
typename ImageSamplerType::Pointer ImageSamplerPointer
typename InterpolatorType::ContinuousIndexType MovingImageContinuousIndexType
typename AdvancedTransformType::NumberOfParametersType NumberOfParametersType
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
itkPadStruct(ITK_CACHE_LINE_ALIGNMENT, KappaGetValueAndDerivativePerThreadStruct, PaddedKappaGetValueAndDerivativePerThreadStruct)
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
void AfterThreadedGetValueAndDerivative(MeasureType &value, DerivativeType &derivative) const override
void PrintSelf(std::ostream &os, Indent indent) const override
static ITK_THREAD_RETURN_FUNCTION_CALL_CONVENTION AccumulateDerivativesThreaderCallback(void *arg)
void ThreadedGetValueAndDerivative(ThreadIdType threadID) const override
ITK_DISALLOW_COPY_AND_MOVE(AdvancedKappaStatisticImageToImageMetric)
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const override
MeasureType GetValue(const ParametersType &parameters) const override
void UpdateValueAndDerivativeTerms(const RealType fixedImageValue, const RealType movingImageValue, std::vcl_size_t &fixedForegroundArea, std::vcl_size_t &movingForegroundArea, std::vcl_size_t &intersection, const DerivativeType &imageJacobian, const NonZeroJacobianIndicesType &nzji, DerivativeType &sum1, DerivativeType &sum2) const
virtual void GetValueAndDerivativeSingleThreaded(const ParametersType &parameters, MeasureType &Value, DerivativeType &Derivative) const
itkStaticConstMacro(MovingImageDimension, unsigned int, MovingImageType::ImageDimension)
itkOverrideGetNameOfClassMacro(AdvancedKappaStatisticImageToImageMetric)
AdvancedImageToImageMetric< typename MetricBase< TElastix >::FixedImageType, typename MetricBase< TElastix >::MovingImageType > Superclass
void InitializeThreadingParameters() const override
~AdvancedKappaStatisticImageToImageMetric() override=default
itkAlignedTypedef(ITK_CACHE_LINE_ALIGNMENT, PaddedKappaGetValueAndDerivativePerThreadStruct, AlignedKappaGetValueAndDerivativePerThreadStruct)


Generated on 26-02-2026 for elastix by doxygen 1.16.1 (669aeeefca743c148e2d935b3d3c69535c7491e6) elastix logo