ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.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 __itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader_h
19 #define __itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader_h
20 
25 
26 #include <deque>
27 
28 namespace itk
29 {
30 
35 template<class T>
37 {
38  typedef T MyType;
39 };
40 
56 template< class TDomainPartitioner, class TImageToImageMetric, class TNeighborhoodCorrelationMetric >
58  : public ImageToImageMetricv4GetValueAndDerivativeThreader< TDomainPartitioner, TImageToImageMetric >
59 {
60 public:
67 
69 
70  itkNewMacro( Self );
71 
72  typedef typename Superclass::DomainType DomainType;
73  typedef typename Superclass::AssociateType AssociateType;
74 
75  typedef typename Superclass::VirtualImageType VirtualImageType;
76  typedef typename Superclass::VirtualPointType VirtualPointType;
77  typedef typename Superclass::VirtualIndexType VirtualIndexType;
78  typedef typename Superclass::FixedImagePointType FixedImagePointType;
79  typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
80  typedef typename Superclass::FixedImageGradientType FixedImageGradientType;
81  typedef typename Superclass::MovingImagePointType MovingImagePointType;
82  typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
83  typedef typename Superclass::MovingImageGradientType MovingImageGradientType;
84  typedef typename Superclass::MeasureType MeasureType;
85  typedef typename Superclass::DerivativeType DerivativeType;
86  typedef typename Superclass::DerivativeValueType DerivativeValueType;
87 
88  typedef TNeighborhoodCorrelationMetric NeighborhoodCorrelationMetricType;
89 
90  typedef typename NeighborhoodCorrelationMetricType::ImageRegionType ImageRegionType;
91  typedef typename NeighborhoodCorrelationMetricType::InternalComputationValueType InternalComputationValueType;
92  typedef typename NeighborhoodCorrelationMetricType::ImageDimensionType ImageDimensionType;
93  typedef typename NeighborhoodCorrelationMetricType::JacobianType JacobianType;
94  typedef typename NeighborhoodCorrelationMetricType::NumberOfParametersType NumberOfParametersType;
95  typedef typename NeighborhoodCorrelationMetricType::FixedImageType FixedImageType;
96  typedef typename NeighborhoodCorrelationMetricType::MovingImageType MovingImageType;
97  typedef typename NeighborhoodCorrelationMetricType::RadiusType RadiusType;
98 
99  // interested values here updated during scanning
101  typedef std::deque<QueueRealType> SumQueueType;
103 
104  // one ScanMemType for each thread
105  typedef struct ScanMemType {
106  // queues used in the scanning
107  // sum of the fixed value squared
109  // sum of the moving value squared
115 
121 
124 
128  } ScanMemType;
129 
130  // For dense scan over one image region
131  typedef struct ScanParametersType {
132  // const values during scanning
134  SizeValueType numberOfFillZero; // for each queue
135  SizeValueType windowLength; // number of voxels in the scanning window
137 
138  typename FixedImageType::ConstPointer fixedImage;
139  typename MovingImageType::ConstPointer movingImage;
140  typename VirtualImageType::ConstPointer virtualImage;
142 
144 
145 protected:
147 
181  virtual bool ProcessVirtualPoint( const VirtualIndexType & virtualIndex,
182  const VirtualPointType & virtualPoint,
183  const ThreadIdType threadId ) {
184  return ProcessVirtualPoint_impl(IdentityHelper<TDomainPartitioner>(), virtualIndex, virtualPoint, threadId );
185  }
186 
187  /* specific overloading for sparse CC metric */
190  const VirtualIndexType & virtualIndex,
191  const VirtualPointType & virtualPoint,
192  const ThreadIdType threadId );
193 
194  /* for other default case */
195  template<class T>
197  IdentityHelper<T> itkNotUsed(self),
198  const VirtualIndexType & virtualIndex,
199  const VirtualPointType & virtualPoint,
200  const ThreadIdType threadId ) {
201  return Superclass::ProcessVirtualPoint(virtualIndex, virtualPoint, threadId);
202  }
203 
204 
208  virtual bool ProcessPoint(
209  const VirtualIndexType & itkNotUsed(virtualIndex),
210  const VirtualPointType & itkNotUsed(virtualPoint),
211  const FixedImagePointType & itkNotUsed(mappedFixedPoint),
212  const FixedImagePixelType & itkNotUsed(mappedFixedPixelValue),
213  const FixedImageGradientType & itkNotUsed(mappedFixedImageGradient),
214  const MovingImagePointType & itkNotUsed(mappedMovingPoint),
215  const MovingImagePixelType & itkNotUsed(mappedMovingPixelValue),
216  const MovingImageGradientType & itkNotUsed(mappedMovingImageGradient),
217  MeasureType & itkNotUsed(metricValueReturn),
218  DerivativeType & itkNotUsed(localDerivativeReturn),
219  const ThreadIdType itkNotUsed(threadID) ) const
220  {
221  itkExceptionMacro("ProcessPoint should never be reached in ANTS CC metric threader class.");
222  }
223 
224  virtual void ThreadedExecution( const DomainType& domain,
225  const ThreadIdType threadId ){
227  }
228 
229  /* specific overloading for dense threader only based CC metric */
232  const DomainType& domain,
233  const ThreadIdType threadId );
234 
235  /* for other default case */
236  template<class T>
238  IdentityHelper<T> itkNotUsed(self),
239  const DomainType& domain,
240  const ThreadIdType threadId );
241 
245  void InitializeScanning(const ImageRegionType &scanRegion,
246  ScanIteratorType &scanIt, ScanMemType &scanMem,
247  ScanParametersType &scanParameters ) const;
248 
251  void UpdateQueues(const ScanIteratorType &scanIt,
252  ScanMemType &scanMem, const ScanParametersType &scanParameters,
253  const ThreadIdType threadID) const;
254 
256  const ScanIteratorType &scanIt, ScanMemType &scanMem,
257  const ScanParametersType &scanParameters,
258  const ThreadIdType threadID) const;
259 
264  const ScanIteratorType &scanIt, ScanMemType &scanMem,
265  const ScanParametersType &scanParameters,
266  const ThreadIdType threadID) const;
267 
271  const ScanIteratorType &scanIt, ScanMemType &scanMem,
272  const ScanParametersType &scanParameters,
273  const ThreadIdType threadID) const;
274 
276  const ScanIteratorType &scanIt, ScanMemType &scanMem,
277  const ScanParametersType &scanParameters, DerivativeType &deriv,
278  MeasureType &local_cc, const ThreadIdType threadID) const;
279 
280 private:
282  void operator=( const Self & ); // purposely not implemented
283 
286  TNeighborhoodCorrelationMetric * m_ANTSAssociate;
287 };
288 
289 
290 } // end namespace itk
291 
292 #ifndef ITK_MANUAL_INSTANTIATION
293 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx"
294 #endif
295 
296 #endif
297