go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkTransformRigidityPenaltyTerm.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 itkTransformRigidityPenaltyTerm_h
19#define itkTransformRigidityPenaltyTerm_h
20
22
26
28#include "itkNeighborhood.h"
29#include "itkImageRegionIterator.h"
30#include "itkNeighborhoodOperatorImageFilter.h"
31#include "itkNeighborhoodIterator.h"
32
34#include "itkGrayscaleDilateImageFilter.h"
35#include "itkBinaryBallStructuringElement.h"
36#include "itkImageRegionIterator.h"
37
38namespace itk
39{
70template <class TFixedImage, class TScalarType>
71class ITK_TEMPLATE_EXPORT TransformRigidityPenaltyTerm : public TransformPenaltyTerm<TFixedImage, TScalarType>
72{
73public:
75
79 using Pointer = SmartPointer<Self>;
80 using ConstPointer = SmartPointer<const Self>;
81
83 itkNewMacro(Self);
84
87
89 using typename Superclass::CoordinateRepresentationType;
90 using typename Superclass::MovingImageType;
91 using typename Superclass::MovingImagePixelType;
92 using typename Superclass::MovingImagePointer;
93 using typename Superclass::MovingImageConstPointer;
94 using typename Superclass::FixedImageType;
95 using typename Superclass::FixedImagePointer;
96 using typename Superclass::FixedImageConstPointer;
97 using typename Superclass::FixedImageRegionType;
98 using typename Superclass::TransformType;
99 using typename Superclass::TransformPointer;
100 using typename Superclass::InputPointType;
101 using typename Superclass::OutputPointType;
102 using typename Superclass::TransformParametersType;
103 using typename Superclass::TransformJacobianType;
104 using typename Superclass::InterpolatorType;
105 using typename Superclass::InterpolatorPointer;
106 using typename Superclass::RealType;
107 using typename Superclass::GradientPixelType;
108 using typename Superclass::GradientImageType;
109 using typename Superclass::GradientImagePointer;
110 using typename Superclass::FixedImageMaskType;
112 using typename Superclass::MovingImageMaskType;
114 using typename Superclass::MeasureType;
115 using typename Superclass::DerivativeType;
116 using typename Superclass::DerivativeValueType;
117 using typename Superclass::ParametersType;
118 using typename Superclass::FixedImagePixelType;
121 using typename Superclass::ScalarType;
122
131
133 using typename Superclass::SpatialJacobianType;
135 using typename Superclass::SpatialHessianType;
137 using typename Superclass::InternalMatrixType;
138
140 itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension);
141 itkStaticConstMacro(MovingImageDimension, unsigned int, FixedImageType::ImageDimension);
142 itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension);
143
145 void
146 Initialize() override;
147
153 using CoefficientImagePointer = typename CoefficientImageType::Pointer;
154 using CoefficientImageSpacingType = typename CoefficientImageType::SpacingType;
155
157 using NeighborhoodType = Neighborhood<ScalarType, Self::FixedImageDimension>;
158 using NeighborhoodSizeType = typename NeighborhoodType::SizeType;
159 using CoefficientImageIteratorType = ImageRegionIterator<CoefficientImageType>;
160 using NOIFType = NeighborhoodOperatorImageFilter<CoefficientImageType, CoefficientImageType>;
161 using NeighborhoodIteratorType = NeighborhoodIterator<CoefficientImageType>;
162 using RadiusType = typename NeighborhoodIteratorType::RadiusType;
163
166 using RigidityImagePointer = typename RigidityImageType::Pointer;
167 using RigidityPixelType = typename RigidityImageType::PixelType;
168 using RigidityImageRegionType = typename RigidityImageType::RegionType;
169 using RigidityImageIndexType = typename RigidityImageType::IndexType;
170 using RigidityImagePointType = typename RigidityImageType::PointType;
171 using RigidityImageIteratorType = ImageRegionIterator<RigidityImageType>;
172 using StructuringElementType = BinaryBallStructuringElement<RigidityPixelType, Self::FixedImageDimension>;
173 using SERadiusType = typename StructuringElementType::RadiusType;
174 using DilateFilterType = GrayscaleDilateImageFilter<RigidityImageType, RigidityImageType, StructuringElementType>;
175 using DilateFilterPointer = typename DilateFilterType::Pointer;
176
178 void
180
182 MeasureType
183 GetValue(const ParametersType & parameters) const override;
184
186 void
187 GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const override;
188
190 void
191 BeforeThreadedGetValueAndDerivative(const TransformParametersType & parameters) const override;
192
194 void
195 GetValueAndDerivative(const ParametersType & parameters,
196 MeasureType & value,
197 DerivativeType & derivative) const override;
198
203
205 // itkSetObjectMacro( RigidityCoefficientImage, RigidityImageType );
206
208 itkSetClampMacro(LinearityConditionWeight, ScalarType, 0.0, NumericTraits<ScalarType>::max());
209 itkGetConstMacro(LinearityConditionWeight, ScalarType);
210
212 itkSetClampMacro(OrthonormalityConditionWeight, ScalarType, 0.0, NumericTraits<ScalarType>::max());
213 itkGetConstMacro(OrthonormalityConditionWeight, ScalarType);
214
216 itkSetClampMacro(PropernessConditionWeight, ScalarType, 0.0, NumericTraits<ScalarType>::max());
217 itkGetConstMacro(PropernessConditionWeight, ScalarType);
218
220 itkSetMacro(UseLinearityCondition, bool);
221
223 itkSetMacro(UseOrthonormalityCondition, bool);
224
226 itkSetMacro(UsePropernessCondition, bool);
227
231 itkSetMacro(CalculateLinearityCondition, bool);
232
236 itkSetMacro(CalculateOrthonormalityCondition, bool);
237
241 itkSetMacro(CalculatePropernessCondition, bool);
242
244 itkGetConstReferenceMacro(LinearityConditionValue, MeasureType);
245
247 itkGetConstReferenceMacro(OrthonormalityConditionValue, MeasureType);
248
250 itkGetConstReferenceMacro(PropernessConditionValue, MeasureType);
251
253 itkGetConstReferenceMacro(LinearityConditionGradientMagnitude, MeasureType);
254
256 itkGetConstReferenceMacro(OrthonormalityConditionGradientMagnitude, MeasureType);
257
259 itkGetConstReferenceMacro(PropernessConditionGradientMagnitude, MeasureType);
260
262 // itkGetConstReferenceMacro( RigidityPenaltyTermValue, MeasureType );
263
265 itkSetMacro(DilateRigidityImages, bool);
266
268 itkSetClampMacro(DilationRadiusMultiplier,
269 CoordinateRepresentationType,
270 0.1,
271 NumericTraits<CoordinateRepresentationType>::max());
272
274 itkSetObjectMacro(FixedRigidityImage, RigidityImageType);
275
277 itkSetObjectMacro(MovingRigidityImage, RigidityImageType);
278
280 itkSetMacro(UseFixedRigidityImage, bool);
281
283 itkSetMacro(UseMovingRigidityImage, bool);
284
286 void
287 FillRigidityCoefficientImage(const ParametersType & parameters) const;
288
289protected:
293 ~TransformRigidityPenaltyTerm() override = default;
294
296 void
297 PrintSelf(std::ostream & os, Indent indent) const override;
298
299private:
301 virtual void
303
305 void
307 const std::string & whichF,
308 const unsigned int WhichDimension,
309 const CoefficientImageSpacingType & spacing) const;
310
312 void
313 CreateNDOperator(NeighborhoodType & F, const std::string & whichF, const CoefficientImageSpacingType & spacing) const;
314
317 FilterSeparable(const CoefficientImageType *, const std::vector<NeighborhoodType> & Operators) const;
318
320 BSplineTransformPointer m_BSplineTransform{};
321 ScalarType m_LinearityConditionWeight{};
322 ScalarType m_OrthonormalityConditionWeight{};
323 ScalarType m_PropernessConditionWeight{};
324
325 mutable MeasureType m_RigidityPenaltyTermValue{};
326 mutable MeasureType m_LinearityConditionValue{};
327 mutable MeasureType m_OrthonormalityConditionValue{};
328 mutable MeasureType m_PropernessConditionValue{};
329 mutable MeasureType m_LinearityConditionGradientMagnitude{};
330 mutable MeasureType m_OrthonormalityConditionGradientMagnitude{};
331 mutable MeasureType m_PropernessConditionGradientMagnitude{};
332
333 bool m_UseLinearityCondition{};
334 bool m_UseOrthonormalityCondition{};
335 bool m_UsePropernessCondition{};
336 bool m_CalculateLinearityCondition{};
337 bool m_CalculateOrthonormalityCondition{};
338 bool m_CalculatePropernessCondition{};
339
341 CoordinateRepresentationType m_DilationRadiusMultiplier{};
342 bool m_DilateRigidityImages{};
343 mutable bool m_RigidityCoefficientImageIsFilled{};
344 RigidityImagePointer m_FixedRigidityImage{};
345 RigidityImagePointer m_MovingRigidityImage{};
346 RigidityImagePointer m_RigidityCoefficientImage{};
347 std::vector<DilateFilterPointer> m_FixedRigidityImageDilation{};
348 std::vector<DilateFilterPointer> m_MovingRigidityImageDilation{};
349 RigidityImagePointer m_FixedRigidityImageDilated{};
350 RigidityImagePointer m_MovingRigidityImageDilated{};
351 bool m_UseFixedRigidityImage{};
352 bool m_UseMovingRigidityImage{};
353};
354
355} // end namespace itk
356
357#ifndef ITK_MANUAL_INSTANTIATION
358# include "itkTransformRigidityPenaltyTerm.hxx"
359#endif
360
361#endif // #ifndef itkTransformRigidityPenaltyTerm_h
Deformable transform using a B-spline representation.
This class combines two transforms: an 'initial transform' with a 'current transform'.
typename BSplineOrder1TransformType::Pointer BSplineOrder1TransformPointer
typename ImageSamplerType::OutputVectorContainerPointer ImageSampleContainerPointer
typename ImageSamplerType::OutputVectorContainerType ImageSampleContainerType
ImageMaskSpatialObject< Self::FixedImageDimension > FixedImageMaskType
typename BSplineOrder3TransformType::Pointer BSplineOrder3TransformPointer
typename BSplineOrder2TransformType::Pointer BSplineOrder2TransformPointer
ImageMaskSpatialObject< Self::MovingImageDimension > MovingImageMaskType
A cost function that calculates a penalty term on a transformation.
typename TransformType::JacobianOfSpatialJacobianType JacobianOfSpatialJacobianType
typename Superclass::AdvancedTransformType TransformType
typename TransformType::SpatialHessianType SpatialHessianType
typename TransformType::SpatialJacobianType SpatialJacobianType
typename TransformType::InternalMatrixType InternalMatrixType
typename TransformType::JacobianOfSpatialHessianType JacobianOfSpatialHessianType
A cost function that calculates a rigidity penalty term.
itkStaticConstMacro(FixedImageDimension, unsigned int, FixedImageType::ImageDimension)
void FillRigidityCoefficientImage(const ParametersType &parameters) const
NeighborhoodOperatorImageFilter< CoefficientImageType, CoefficientImageType > NOIFType
CoefficientImagePointer FilterSeparable(const CoefficientImageType *, const std::vector< NeighborhoodType > &Operators) const
MeasureType GetValue(const ParametersType &parameters) const override
void BeforeThreadedGetValueAndDerivative(const TransformParametersType &parameters) const override
typename BSplineTransformType::SpacingType GridSpacingType
itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension)
typename CoefficientImageType::SpacingType CoefficientImageSpacingType
typename NeighborhoodType::SizeType NeighborhoodSizeType
itkStaticConstMacro(MovingImageDimension, unsigned int, FixedImageType::ImageDimension)
typename RigidityImageType::RegionType RigidityImageRegionType
GrayscaleDilateImageFilter< RigidityImageType, RigidityImageType, StructuringElementType > DilateFilterType
void Create1DOperator(NeighborhoodType &F, const std::string &whichF, const unsigned int WhichDimension, const CoefficientImageSpacingType &spacing) const
void CreateNDOperator(NeighborhoodType &F, const std::string &whichF, const CoefficientImageSpacingType &spacing) const
Neighborhood< ScalarType, Self::FixedImageDimension > NeighborhoodType
void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const override
NeighborhoodIterator< CoefficientImageType > NeighborhoodIteratorType
typename DilateFilterType::Pointer DilateFilterPointer
BinaryBallStructuringElement< RigidityPixelType, Self::FixedImageDimension > StructuringElementType
typename BSplineTransformType::ImageType CoefficientImageType
typename BSplineTransformType::Pointer BSplineTransformPointer
void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const override
ImageRegionIterator< RigidityImageType > RigidityImageIteratorType
typename RigidityImageType::Pointer RigidityImagePointer
typename RigidityImageType::PointType RigidityImagePointType
void PrintSelf(std::ostream &os, Indent indent) const override
typename StructuringElementType::RadiusType SERadiusType
typename CoefficientImageType::Pointer CoefficientImagePointer
typename RigidityImageType::PixelType RigidityPixelType
ITK_DISALLOW_COPY_AND_MOVE(TransformRigidityPenaltyTerm)
typename RigidityImageType::IndexType RigidityImageIndexType
~TransformRigidityPenaltyTerm() override=default
ImageRegionIterator< CoefficientImageType > CoefficientImageIteratorType
typename NeighborhoodIteratorType::RadiusType RadiusType


Generated on 2024-07-17 for elastix by doxygen 1.11.0 (9b424b03c9833626cd435af22a444888fbbb192d) elastix logo