ITK  4.4.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 
84 template<unsigned int TFixedDimension, unsigned int TMovingDimension, class TVirtualImage = Image<typename ObjectToObjectMetricBase::ParametersValueType, TFixedDimension> >
85 class ITK_EXPORT ObjectToObjectMetric:
87 {
88 public:
94 
97 
99  typedef typename Superclass::ParametersValueType CoordinateRepresentationType;
100 
102  typedef typename Superclass::InternalComputationValueType InternalComputationValueType;
103 
105  typedef typename Superclass::MeasureType MeasureType;
106 
108  typedef typename Superclass::DerivativeType DerivativeType;
109  typedef typename Superclass::DerivativeValueType DerivativeValueType;
110 
112  typedef typename Superclass::ParametersType ParametersType;
113  typedef typename Superclass::ParametersValueType ParametersValueType;
114  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
115 
118 
120  itkStaticConstMacro(FixedDimension, DimensionType, TFixedDimension);
121  itkStaticConstMacro(MovingDimension, DimensionType, TMovingDimension);
122  itkStaticConstMacro(VirtualDimension, DimensionType, TVirtualImage::ImageDimension);
124 
126  typedef TVirtualImage VirtualImageType;
131  typedef typename VirtualRegionType::SizeType VirtualSizeType;
138 
142 
146 
151 
156 
161 
164 
165  virtual void Initialize(void) throw ( ExceptionObject );
166 
167  virtual NumberOfParametersType GetNumberOfParameters() const;
168  virtual NumberOfParametersType GetNumberOfLocalParameters() const;
169  virtual void SetParameters( ParametersType & params );
170  virtual const ParametersType & GetParameters() const;
171  virtual bool HasLocalSupport() const;
172  virtual void UpdateTransformParameters( const DerivativeType & derivative, ParametersValueType factor);
173 
175  itkSetObjectMacro(FixedTransform, FixedTransformType);
176 
178  itkGetModifiableObjectMacro(FixedTransform, FixedTransformType);
179 
181  itkSetObjectMacro(MovingTransform, MovingTransformType);
182 
184  itkGetModifiableObjectMacro(MovingTransform, MovingTransformType);
185 
188  void SetTransform( MovingTransformType* transform );
189 
191  const MovingTransformType * GetTransform();
192 
195  itkGetConstMacro(NumberOfValidPoints, SizeValueType)
196 
213  void SetVirtualDomain( const VirtualSpacingType & spacing, const VirtualOriginType & origin,
214  const VirtualDirectionType & direction, const VirtualRegionType & region );
215 
218  void SetVirtualDomainFromImage( VirtualImageType * virtualImage);
219  void SetVirtualDomainFromImage( const VirtualImageType * virtualImage);
221 
226  virtual bool SupportsArbitraryVirtualDomainSamples( void ) const = 0;
227 
233  virtual const TimeStamp& GetVirtualDomainTimeStamp( void ) const;
234 
237  VirtualSpacingType GetVirtualSpacing( void ) const;
238 
241  VirtualOriginType GetVirtualOrigin( void ) const;
242 
245  VirtualDirectionType GetVirtualDirection( void ) const;
246 
249  const VirtualRegionType & GetVirtualRegion( void ) const;
250 
251  itkGetModifiableObjectMacro(VirtualImage, VirtualImageType );
252 
262  OffsetValueType ComputeParameterOffsetFromVirtualIndex( const VirtualIndexType & index, const NumberOfParametersType &numberOfLocalParameters ) const;
263 
273  OffsetValueType ComputeParameterOffsetFromVirtualPoint( const VirtualPointType & point, const NumberOfParametersType & numberOfLocalParameters ) const;
274 
279  bool IsInsideVirtualDomain( const VirtualPointType & point ) const;
280  bool IsInsideVirtualDomain( const VirtualIndexType & index ) const;
282 
283 protected:
285  virtual ~ObjectToObjectMetric();
286 
287  void PrintSelf(std::ostream & os, Indent indent) const;
288 
291  virtual void VerifyDisplacementFieldSizeAndPhysicalSpace();
292 
293  bool TransformPhysicalPointToVirtualIndex( const VirtualPointType &, VirtualIndexType & ) const;
294  void TransformVirtualIndexToPhysicalPoint( const VirtualIndexType &, VirtualPointType & ) const;
295 
300  MovingDisplacementFieldTransformType * GetMovingDisplacementFieldTransform() const;
301 
308  bool VerifyNumberOfValidPoints( MeasureType & value, DerivativeType & derivative ) const;
309 
311  FixedTransformPointer m_FixedTransform;
312  MovingTransformPointer m_MovingTransform;
313 
314  VirtualImagePointer m_VirtualImage;
315 
318  bool m_UserHasSetVirtualDomain;
319 
323  mutable SizeValueType m_NumberOfValidPoints;
324 
325 private:
326  ObjectToObjectMetric(const Self &); //purposely not implemented
327  void operator=(const Self &); //purposely not implemented
328 
329 };
330 } // end namespace itk
331 
332 #ifndef ITK_MANUAL_INSTANTIATION
333 #include "itkObjectToObjectMetric.hxx"
334 #endif
335 
336 #endif
337