ITK  4.8.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>
90  public ObjectToObjectMetricBaseTemplate<TParametersValueType>
91 {
92 public:
98 
101 
103  typedef TParametersValueType CoordinateRepresentationType;
104 
106  typedef TParametersValueType InternalComputationValueType;
107 
110 
112  typedef typename Superclass::Object ObjectType;
113 
117 
121 
123 
126 
128  itkStaticConstMacro(FixedDimension, DimensionType, TFixedDimension);
129  itkStaticConstMacro(MovingDimension, DimensionType, TMovingDimension);
130  itkStaticConstMacro(VirtualDimension, DimensionType, TVirtualImage::ImageDimension);
132 
134  typedef TVirtualImage VirtualImageType;
135  typedef typename VirtualImageType::Pointer VirtualImagePointer;
139  typedef typename VirtualRegionType::SizeType VirtualSizeType;
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) throw ( ExceptionObject ) 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 
248 
252 
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  {
299  }
300 
301 protected:
303  virtual ~ObjectToObjectMetric();
304 
305  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
306 
310 
313 
319 
326  bool VerifyNumberOfValidPoints( MeasureType & value, DerivativeType & derivative ) const;
327 
331 
333 
337 
342 
343 private:
344  ObjectToObjectMetric(const Self &); //purposely not implemented
345  void operator=(const Self &); //purposely not implemented
346 
347 };
348 } // end namespace itk
349 
350 #ifndef ITK_MANUAL_INSTANTIATION
351 #include "itkObjectToObjectMetric.hxx"
352 #endif
353 
354 #endif
void SetVirtualDomain(const VirtualSpacingType &spacing, const VirtualOriginType &origin, const VirtualDirectionType &direction, const VirtualRegionType &region)
Superclass::ParametersType ParametersType
Transform< TParametersValueType, TVirtualImage::ImageDimension, TMovingDimension > MovingTransformType
void operator=(const Self &)
Superclass::RegionType RegionType
Definition: itkImage.h:140
SmartPointer< const Self > ConstPointer
MovingTransformType::InputPointType MovingInputPointType
Light weight base class for most itk classes.
bool VerifyNumberOfValidPoints(MeasureType &value, DerivativeType &derivative) const
virtual bool HasLocalSupport() const override
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
bool TransformPhysicalPointToVirtualIndex(const VirtualPointType &, VirtualIndexType &) const
VirtualSpacingType GetVirtualSpacing() const
Transform< TParametersValueType, TVirtualImage::ImageDimension, TFixedDimension > FixedTransformType
FixedTransformType::Pointer FixedTransformPointer
virtual void VerifyDisplacementFieldSizeAndPhysicalSpace()
virtual bool SupportsArbitraryVirtualDomainSamples(void) const =0
Computes similarity between regions of two objects.
virtual void SetParameters(ParametersType &params) override
void TransformVirtualIndexToPhysicalPoint(const VirtualIndexType &, VirtualPointType &) const
VirtualImageType::ConstPointer VirtualImageConstPointer
Base class for all object-to-object similarlity metrics added in ITKv4.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
OffsetValueType ComputeParameterOffsetFromVirtualIndex(const VirtualIndexType &index, const NumberOfParametersType &numberOfLocalParameters) const
TPixel PixelType
Definition: itkImage.h:89
VirtualPointSetType::Pointer VirtualPointSetPointer
void SetTransform(MovingTransformType *transform)
FixedTransformType::OutputPointType FixedOutputPointType
VirtualImageType::SpacingType VirtualSpacingType
VirtualImageType::IndexType VirtualIndexType
void PrintSelf(std::ostream &os, Indent indent) const override
FixedTransformType::ParametersType FixedTransformParametersType
const VirtualRegionType & GetVirtualRegion() const
VirtualImageType::RegionType VirtualRegionType
bool IsInsideVirtualDomain(const VirtualPointType &point) const
const MovingDisplacementFieldTransformType * GetMovingDisplacementFieldTransform() const
virtual NumberOfParametersType GetNumberOfLocalParameters() const override
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
static const DimensionType VirtualDimension
Class to hold and manage different parameter types used during optimization.
Superclass::MeasureType MeasureType
Superclass::IndexType IndexType
Definition: itkImage.h:122
VirtualImageType::DirectionType VirtualDirectionType
Superclass::DerivativeType DerivativeType
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:84
VirtualOriginType GetVirtualOrigin() const
static const DimensionType MovingDimension
MovingTransformType::JacobianType MovingTransformJacobianType
VirtualDirectionType GetVirtualDirection() const
Standard exception handling object.
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:58
FixedTransformPointer m_FixedTransform
VirtualImageType::PointType VirtualPointType
const MovingTransformType * GetTransform()
DisplacementFieldTransform< CoordinateRepresentationType, itkGetStaticConstMacro(MovingDimension) > MovingDisplacementFieldTransformType
TParametersValueType CoordinateRepresentationType
TParametersValueType InternalComputationValueType
VirtualRegionType::SizeType VirtualSizeType
FixedTransformType::JacobianType JacobianType
VirtualImageType::PointType VirtualOriginType
virtual const ParametersType & GetParameters() const override
virtual MetricCategoryType GetMetricCategory() const override
virtual NumberOfParametersType GetNumberOfParameters() const override
MovingTransformType::OutputPointType MovingOutputPointType
static const DimensionType FixedDimension
Control indentation during Print() invocation.
Definition: itkIndent.h:49
MovingTransformType::Pointer MovingTransformPointer
PointSet< VirtualPixelType, itkGetStaticConstMacro(VirtualDimension)> VirtualPointSetType
virtual void Initialize(void) override
virtual const TimeStamp & GetVirtualDomainTimeStamp() const
void SetVirtualDomainFromImage(const VirtualImageType *virtualImage)
MovingTransformPointer m_MovingTransform
ObjectToObjectMetricBaseTemplate< TParametersValueType > Superclass
FixedTransformType::JacobianType FixedTransformJacobianType
Templated n-dimensional image class.
Definition: itkImage.h:75
Superclass::NumberOfParametersType NumberOfParametersType
Superclass::DerivativeValueType DerivativeValueType
virtual void UpdateTransformParameters(const DerivativeType &derivative, TParametersValueType factor) override
OffsetValueType ComputeParameterOffsetFromVirtualPoint(const VirtualPointType &point, const NumberOfParametersType &numberOfLocalParameters) const
VirtualImageType::Pointer VirtualImagePointer
Superclass::GradientSourceType GradientSourceType