ITK  4.6.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<typename T>
37 {
38  typedef T MyType;
39 };
40 
56 template< typename TDomainPartitioner, typename TImageToImageMetric, typename 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  m_ANTSAssociate(ITK_NULLPTR)
148  {}
149 
183  virtual bool ProcessVirtualPoint( const VirtualIndexType & virtualIndex,
184  const VirtualPointType & virtualPoint,
185  const ThreadIdType threadId ) {
186  return ProcessVirtualPoint_impl(IdentityHelper<TDomainPartitioner>(), virtualIndex, virtualPoint, threadId );
187  }
188 
189  /* specific overloading for sparse CC metric */
192  const VirtualIndexType & virtualIndex,
193  const VirtualPointType & virtualPoint,
194  const ThreadIdType threadId );
195 
196  /* for other default case */
197  template<typename T>
199  IdentityHelper<T> itkNotUsed(self),
200  const VirtualIndexType & virtualIndex,
201  const VirtualPointType & virtualPoint,
202  const ThreadIdType threadId ) {
203  return Superclass::ProcessVirtualPoint(virtualIndex, virtualPoint, threadId);
204  }
205 
206 
210  virtual bool ProcessPoint(
211  const VirtualIndexType & itkNotUsed(virtualIndex),
212  const VirtualPointType & itkNotUsed(virtualPoint),
213  const FixedImagePointType & itkNotUsed(mappedFixedPoint),
214  const FixedImagePixelType & itkNotUsed(mappedFixedPixelValue),
215  const FixedImageGradientType & itkNotUsed(mappedFixedImageGradient),
216  const MovingImagePointType & itkNotUsed(mappedMovingPoint),
217  const MovingImagePixelType & itkNotUsed(mappedMovingPixelValue),
218  const MovingImageGradientType & itkNotUsed(mappedMovingImageGradient),
219  MeasureType & itkNotUsed(metricValueReturn),
220  DerivativeType & itkNotUsed(localDerivativeReturn),
221  const ThreadIdType itkNotUsed(threadId) ) const
222  {
223  itkExceptionMacro("ProcessPoint should never be reached in ANTS CC metric threader class.");
224  }
225 
226  virtual void ThreadedExecution( const DomainType& domain,
227  const ThreadIdType threadId ){
229  }
230 
231  /* specific overloading for dense threader only based CC metric */
234  const DomainType& domain,
235  const ThreadIdType threadId );
236 
237  /* for other default case */
238  template<typename T>
240  IdentityHelper<T> itkNotUsed(self),
241  const DomainType& domain,
242  const ThreadIdType threadId );
243 
247  void InitializeScanning(const ImageRegionType &scanRegion,
248  ScanIteratorType &scanIt, ScanMemType &scanMem,
249  ScanParametersType &scanParameters ) const;
250 
253  void UpdateQueues(const ScanIteratorType &scanIt,
254  ScanMemType &scanMem, const ScanParametersType &scanParameters,
255  const ThreadIdType threadId) const;
256 
258  const ScanIteratorType &scanIt, ScanMemType &scanMem,
259  const ScanParametersType &scanParameters,
260  const ThreadIdType threadId) const;
261 
266  const ScanIteratorType &scanIt, ScanMemType &scanMem,
267  const ScanParametersType &scanParameters,
268  const ThreadIdType threadId) const;
269 
273  const ScanIteratorType &scanIt, ScanMemType &scanMem,
274  const ScanParametersType &scanParameters,
275  const ThreadIdType threadId) const;
276 
278  const ScanIteratorType &scanIt, ScanMemType &scanMem,
279  const ScanParametersType &scanParameters, DerivativeType &deriv,
280  MeasureType &local_cc, const ThreadIdType threadId) const;
281 
282 private:
284  void operator=( const Self & ); // purposely not implemented
285 
288  TNeighborhoodCorrelationMetric * m_ANTSAssociate;
289 };
290 
291 
292 } // end namespace itk
293 
294 #ifndef ITK_MANUAL_INSTANTIATION
295 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx"
296 #endif
297 
298 #endif
signed long IndexValueType
Definition: itkIntTypes.h:150
Class for partitioning of an ImageRegion.
void ThreadedExecution_impl(IdentityHelper< ThreadedImageRegionPartitioner< TImageToImageMetric::VirtualImageDimension > >, const DomainType &domain, const ThreadIdType threadId)
virtual bool ProcessPoint(const VirtualIndexType &, const VirtualPointType &, const FixedImagePointType &, const FixedImagePixelType &, const FixedImageGradientType &, const MovingImagePointType &, const MovingImagePixelType &, const MovingImageGradientType &, MeasureType &, DerivativeType &, const ThreadIdType) const
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
unsigned long SizeValueType
Definition: itkIntTypes.h:143
void UpdateQueues(const ScanIteratorType &scanIt, ScanMemType &scanMem, const ScanParametersType &scanParameters, const ThreadIdType threadId) const
bool ProcessVirtualPoint_impl(IdentityHelper< T >, const VirtualIndexType &virtualIndex, const VirtualPointType &virtualPoint, const ThreadIdType threadId)
void InitializeScanning(const ImageRegionType &scanRegion, ScanIteratorType &scanIt, ScanMemType &scanMem, ScanParametersType &scanParameters) const
void UpdateQueuesToNextScanWindow(const ScanIteratorType &scanIt, ScanMemType &scanMem, const ScanParametersType &scanParameters, const ThreadIdType threadId) const
bool ComputeInformationFromQueues(const ScanIteratorType &scanIt, ScanMemType &scanMem, const ScanParametersType &scanParameters, const ThreadIdType threadId) const
struct itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader::ScanParametersType ScanParametersType
bool ProcessVirtualPoint_impl(IdentityHelper< ThreadedIndexedContainerPartitioner >, const VirtualIndexType &virtualIndex, const VirtualPointType &virtualPoint, const ThreadIdType threadId)
Provides threading for ImageToImageMetricv4::GetValueAndDerivative.
struct itk::ANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader::ScanMemType ScanMemType
void UpdateQueuesAtBeginningOfLine(const ScanIteratorType &scanIt, ScanMemType &scanMem, const ScanParametersType &scanParameters, const ThreadIdType threadId) const
void ComputeMovingTransformDerivative(const ScanIteratorType &scanIt, ScanMemType &scanMem, const ScanParametersType &scanParameters, DerivativeType &deriv, MeasureType &local_cc, const ThreadIdType threadId) const
virtual bool ProcessVirtualPoint(const VirtualIndexType &virtualIndex, const VirtualPointType &virtualPoint, const ThreadIdType threadId)
unsigned int ThreadIdType
Definition: itkIntTypes.h:159