ITK  4.2.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 #include "itkTransform.h"
23 #include "itkImage.h"
25 #include "itkPointSet.h"
26 
27 namespace itk
28 {
29 
85 template<unsigned int TFixedDimension, unsigned int TMovingDimension, class TVirtualImage = Image<typename ObjectToObjectMetricBase::ParametersValueType, TFixedDimension> >
86 class ITK_EXPORT ObjectToObjectMetric:
88 {
89 public:
95 
98 
100  typedef typename Superclass::ParametersValueType CoordinateRepresentationType;
101 
103  typedef typename Superclass::InternalComputationValueType InternalComputationValueType;
104 
106  typedef typename Superclass::MeasureType MeasureType;
107 
109  typedef typename Superclass::DerivativeType DerivativeType;
110  typedef typename Superclass::DerivativeValueType DerivativeValueType;
111 
113  typedef typename Superclass::ParametersType ParametersType;
114  typedef typename Superclass::ParametersValueType ParametersValueType;
115  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
116 
119 
121  itkStaticConstMacro(FixedDimension, DimensionType, TFixedDimension);
122  itkStaticConstMacro(MovingDimension, DimensionType, TMovingDimension);
123  itkStaticConstMacro(VirtualDimension, DimensionType, TVirtualImage::ImageDimension);
125 
127  typedef TVirtualImage VirtualImageType;
132  typedef typename VirtualRegionType::SizeType VirtualSizeType;
139 
143 
147 
152 
157 
162 
165 
166  virtual void Initialize(void) throw ( ExceptionObject );
167 
168  virtual NumberOfParametersType GetNumberOfParameters() const;
169  virtual NumberOfParametersType GetNumberOfLocalParameters() const;
170  virtual void SetParameters( ParametersType & params );
171  virtual const ParametersType & GetParameters() const;
172  virtual bool HasLocalSupport() const;
173  virtual void UpdateTransformParameters( const DerivativeType & derivative, ParametersValueType factor);
174 
176  itkSetObjectMacro(FixedTransform, FixedTransformType);
177 
179  itkGetConstObjectMacro(FixedTransform, FixedTransformType);
180 
182  itkSetObjectMacro(MovingTransform, MovingTransformType);
183 
185  itkGetConstObjectMacro(MovingTransform, MovingTransformType);
186 
189  void SetTransform( MovingTransformType* transform );
190 
192  const MovingTransformType * GetTransform();
193 
196  itkGetConstMacro(NumberOfValidPoints, SizeValueType)
197 
214  void SetVirtualDomain( const VirtualSpacingType & spacing, const VirtualOriginType & origin,
215  const VirtualDirectionType & direction, const VirtualRegionType & region );
216 
219  void SetVirtualDomainFromImage( VirtualImageType * virtualImage);
220  void SetVirtualDomainFromImage( const VirtualImageType * virtualImage);
222 
227  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const = 0;
228 
234  virtual const TimeStamp& GetVirtualDomainTimeStamp( void ) const;
235 
238  VirtualSpacingType GetVirtualSpacing( void ) const;
239 
242  VirtualOriginType GetVirtualOrigin( void ) const;
243 
246  VirtualDirectionType GetVirtualDirection( void ) const;
247 
250  const VirtualRegionType & GetVirtualRegion( void ) const;
251 
252  itkGetConstObjectMacro( VirtualImage, VirtualImageType );
253 
263  OffsetValueType ComputeParameterOffsetFromVirtualIndex( const VirtualIndexType & index, const NumberOfParametersType &numberOfLocalParameters ) const;
264 
274  OffsetValueType ComputeParameterOffsetFromVirtualPoint( const VirtualPointType & point, const NumberOfParametersType & numberOfLocalParameters ) const;
275 
280  bool IsInsideVirtualDomain( const VirtualPointType & point ) const;
281  bool IsInsideVirtualDomain( const VirtualIndexType & index ) const;
283 
284 protected:
286  virtual ~ObjectToObjectMetric();
287 
288  void PrintSelf(std::ostream & os, Indent indent) const;
289 
292  virtual void VerifyDisplacementFieldSizeAndPhysicalSpace();
293 
294  bool TransformPhysicalPointToVirtualIndex( const VirtualPointType &, VirtualIndexType & ) const;
295  void TransformVirtualIndexToPhysicalPoint( const VirtualIndexType &, VirtualPointType & ) const;
296 
301  MovingDisplacementFieldTransformType * GetMovingDisplacementFieldTransform() const;
302 
309  bool VerifyNumberOfValidPoints( MeasureType & value, DerivativeType & derivative ) const;
310 
312  FixedTransformPointer m_FixedTransform;
313  MovingTransformPointer m_MovingTransform;
314 
315  VirtualImagePointer m_VirtualImage;
316 
319  bool m_UserHasSetVirtualDomain;
320 
324  mutable SizeValueType m_NumberOfValidPoints;
325 
326 private:
327  ObjectToObjectMetric(const Self &); //purposely not implemented
328  void operator=(const Self &); //purposely not implemented
329 
330 };
331 } // end namespace itk
332 
333 #ifndef ITK_MANUAL_INSTANTIATION
334 #include "itkObjectToObjectMetric.hxx"
335 #endif
336 
337 #endif
338