ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkObjectToObjectMetric.h
Go to the documentation of this file.
1  /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkObjectToObjectMetric_h
19 #define itkObjectToObjectMetric_h
20 
21 
23 
25 #include "itkImage.h"
26 #include "itkObject.h"
27 #include "itkPointSet.h"
28 #include "itkTransform.h"
29 
30 namespace itk
31 {
32 
87 template<unsigned int TFixedDimension, unsigned int TMovingDimension, typename TVirtualImage = Image<double, TFixedDimension>,
88  typename TParametersValueType=double>
89 class ITK_TEMPLATE_EXPORT ObjectToObjectMetric:
90  public ObjectToObjectMetricBaseTemplate<TParametersValueType>
91 {
92 public:
98 
101 
103  typedef TParametersValueType CoordinateRepresentationType;
104 
106  typedef TParametersValueType InternalComputationValueType;
107 
109  typedef typename Superclass::MeasureType MeasureType;
110 
112  typedef typename Superclass::Object ObjectType;
113 
115  typedef typename Superclass::DerivativeType DerivativeType;
116  typedef typename Superclass::DerivativeValueType DerivativeValueType;
117 
119  typedef typename Superclass::ParametersType ParametersType;
120  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
121 
122  typedef typename Superclass::GradientSourceType GradientSourceType;
123 
126 
128  itkStaticConstMacro(FixedDimension, DimensionType, TFixedDimension);
129  itkStaticConstMacro(MovingDimension, DimensionType, TMovingDimension);
130  itkStaticConstMacro(VirtualDimension, DimensionType, TVirtualImage::ImageDimension);
132 
134  typedef TVirtualImage VirtualImageType;
146 
150 
152  typedef Transform<TParametersValueType,
153  TVirtualImage::ImageDimension,
154  TMovingDimension> MovingTransformType;
155  typedef Transform<TParametersValueType,
156  TVirtualImage::ImageDimension,
157  TFixedDimension> FixedTransformType;
158 
163 
168 
173 
176 
177  virtual void Initialize(void) ITK_OVERRIDE;
178 
179  virtual NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE;
180  virtual NumberOfParametersType GetNumberOfLocalParameters() const ITK_OVERRIDE;
181  virtual void SetParameters( ParametersType & params ) ITK_OVERRIDE;
182  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
183  virtual bool HasLocalSupport() const ITK_OVERRIDE;
184  virtual void UpdateTransformParameters( const DerivativeType & derivative, TParametersValueType factor) ITK_OVERRIDE;
185 
187  itkSetObjectMacro(FixedTransform, FixedTransformType);
188 
190  itkGetModifiableObjectMacro(FixedTransform, FixedTransformType);
191 
193  itkSetObjectMacro(MovingTransform, MovingTransformType);
194 
196  itkGetModifiableObjectMacro(MovingTransform, MovingTransformType);
197 
200  void SetTransform( MovingTransformType* transform );
201 
203  const MovingTransformType * GetTransform();
204 
207  itkGetConstMacro(NumberOfValidPoints, SizeValueType)
208 
225  void SetVirtualDomain( const VirtualSpacingType & spacing, const VirtualOriginType & origin,
226  const VirtualDirectionType & direction, const VirtualRegionType & region );
227 
230  void SetVirtualDomainFromImage( const VirtualImageType * virtualImage);
231 
236  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const = 0;
237 
243  virtual const TimeStamp& GetVirtualDomainTimeStamp() const;
244 
247  VirtualSpacingType GetVirtualSpacing() const;
248 
251  VirtualOriginType GetVirtualOrigin() const;
252 
255  VirtualDirectionType GetVirtualDirection() const;
256 
259  const VirtualRegionType & GetVirtualRegion() const;
260 
261  itkGetModifiableObjectMacro(VirtualImage, VirtualImageType );
262 
272  OffsetValueType ComputeParameterOffsetFromVirtualIndex( const VirtualIndexType & index, const NumberOfParametersType &numberOfLocalParameters ) const;
273 
283  OffsetValueType ComputeParameterOffsetFromVirtualPoint( const VirtualPointType & point, const NumberOfParametersType & numberOfLocalParameters ) const;
284 
289  bool IsInsideVirtualDomain( const VirtualPointType & point ) const;
290  bool IsInsideVirtualDomain( const VirtualIndexType & index ) const;
292 
294 
296  virtual MetricCategoryType GetMetricCategory() const ITK_OVERRIDE
297  {
298  return Superclass::OBJECT_METRIC;
299  }
300 
301 protected:
303  virtual ~ObjectToObjectMetric() ITK_OVERRIDE;
304 
305  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
306 
309  virtual void VerifyDisplacementFieldSizeAndPhysicalSpace();
310 
311  bool TransformPhysicalPointToVirtualIndex( const VirtualPointType &, VirtualIndexType & ) const;
312  void TransformVirtualIndexToPhysicalPoint( const VirtualIndexType &, VirtualPointType & ) const;
313 
318  const MovingDisplacementFieldTransformType * GetMovingDisplacementFieldTransform() const;
319 
326  bool VerifyNumberOfValidPoints( MeasureType & value, DerivativeType & derivative ) const;
327 
329  FixedTransformPointer m_FixedTransform;
330  MovingTransformPointer m_MovingTransform;
331 
332  VirtualImagePointer m_VirtualImage;
333 
336  bool m_UserHasSetVirtualDomain;
337 
341  mutable SizeValueType m_NumberOfValidPoints;
342 
343 private:
344  ITK_DISALLOW_COPY_AND_ASSIGN(ObjectToObjectMetric);
345 
346 };
347 } // end namespace itk
348 
349 #ifndef ITK_MANUAL_INSTANTIATION
350 #include "itkObjectToObjectMetric.hxx"
351 #endif
352 
353 #endif
Superclass::ParametersType ParametersType
Transform< TParametersValueType, TVirtualImage::ImageDimension, TMovingDimension > MovingTransformType
Superclass::RegionType RegionType
Definition: itkImage.h:137
SmartPointer< const Self > ConstPointer
MovingTransformType::InputPointType MovingInputPointType
Light weight base class for most itk classes.
Represent the size (bounds) of a n-dimensional image.
Definition: itkSize.h:52
VirtualImageType::PixelType VirtualPixelType
signed long OffsetValueType
Definition: itkIntTypes.h:154
Provides local/dense/high-dimensionaltiy transformation via a a displacement field.
VirtualImageType::SizeType VirtualRadiusType
MovingTransformType::ParametersType MovingTransformParametersType
Transform< TParametersValueType, TVirtualImage::ImageDimension, TFixedDimension > FixedTransformType
FixedTransformType::Pointer FixedTransformPointer
Computes similarity between regions of two objects.
VirtualImageType::ConstPointer VirtualImageConstPointer
Base class for all object-to-object similarlity metrics added in ITKv4.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
TPixel PixelType
Definition: itkImage.h:89
VirtualPointSetType::Pointer VirtualPointSetPointer
FixedTransformType::OutputPointType FixedOutputPointType
VirtualImageType::SpacingType VirtualSpacingType
VirtualImageType::IndexType VirtualIndexType
FixedTransformType::ParametersType FixedTransformParametersType
VirtualImageType::RegionType VirtualRegionType
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
FixedTransformType::InputPointType FixedInputPointType
Array2D class representing a 2D array with size defined at construction time.
Definition: itkArray2D.h:45
Class to hold and manage different parameter types used during optimization.
Superclass::MeasureType MeasureType
VirtualImageType::DirectionType VirtualDirectionType
Superclass::DerivativeType DerivativeType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
MovingTransformType::JacobianType MovingTransformJacobianType
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:59
VirtualImageType::PointType VirtualPointType
DisplacementFieldTransform< CoordinateRepresentationType, itkGetStaticConstMacro(MovingDimension) > MovingDisplacementFieldTransformType
TParametersValueType CoordinateRepresentationType
TParametersValueType InternalComputationValueType
VirtualRegionType::SizeType VirtualSizeType
FixedTransformType::JacobianType JacobianType
VirtualImageType::PointType VirtualOriginType
MovingTransformType::OutputPointType MovingOutputPointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
MovingTransformType::Pointer MovingTransformPointer
PointSet< VirtualPixelType, itkGetStaticConstMacro(VirtualDimension)> VirtualPointSetType
ObjectToObjectMetricBaseTemplate< TParametersValueType > Superclass
FixedTransformType::JacobianType FixedTransformJacobianType
Templated n-dimensional image class.
Definition: itkImage.h:75
Superclass::NumberOfParametersType NumberOfParametersType
Superclass::DerivativeValueType DerivativeValueType
VirtualImageType::Pointer VirtualImagePointer
Superclass::GradientSourceType GradientSourceType