ITK  4.9.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 ) ITK_OVERRIDE {
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 ITK_OVERRIDE
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 ) ITK_OVERRIDE
228  {
230  }
231 
232  /* specific overloading for dense threader only based CC metric */
235  const DomainType& domain,
236  const ThreadIdType threadId );
237 
238  /* for other default case */
239  template<typename T>
241  IdentityHelper<T> itkNotUsed(self),
242  const DomainType& domain,
243  const ThreadIdType threadId );
244 
248  void InitializeScanning(const ImageRegionType &scanRegion,
249  ScanIteratorType &scanIt, ScanMemType &scanMem,
250  ScanParametersType &scanParameters ) const;
251 
254  void UpdateQueues(const ScanIteratorType &scanIt,
255  ScanMemType &scanMem, const ScanParametersType &scanParameters,
256  const ThreadIdType threadId) const;
257 
259  const ScanIteratorType &scanIt, ScanMemType &scanMem,
260  const ScanParametersType &scanParameters,
261  const ThreadIdType threadId) const;
262 
267  const ScanIteratorType &scanIt, ScanMemType &scanMem,
268  const ScanParametersType &scanParameters,
269  const ThreadIdType threadId) const;
270 
274  const ScanIteratorType &scanIt, ScanMemType &scanMem,
275  const ScanParametersType &scanParameters,
276  const ThreadIdType threadId) const;
277 
279  const ScanIteratorType &scanIt, ScanMemType &scanMem,
280  const ScanParametersType &scanParameters, DerivativeType &deriv,
281  MeasureType &local_cc, const ThreadIdType threadId) const;
282 
283 private:
285  void operator=( const Self & ) ITK_DELETE_FUNCTION;
286 
289  TNeighborhoodCorrelationMetric * m_ANTSAssociate;
290 };
291 
292 
293 } // end namespace itk
294 
295 #ifndef ITK_MANUAL_INSTANTIATION
296 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4GetValueAndDerivativeThreader.hxx"
297 #endif
298 
299 #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)
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)
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
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) override
virtual bool ProcessPoint(const VirtualIndexType &, const VirtualPointType &, const FixedImagePointType &, const FixedImagePixelType &, const FixedImageGradientType &, const MovingImagePointType &, const MovingImagePixelType &, const MovingImageGradientType &, MeasureType &, DerivativeType &, const ThreadIdType) const override