ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkANTSNeighborhoodCorrelationImageToImageMetricv4.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 __itkANTSNeighborhoodCorrelationImageToImageMetricv4_h
19 #define __itkANTSNeighborhoodCorrelationImageToImageMetricv4_h
20 
23 
25 
26 #include <deque>
27 
28 namespace itk {
29 
97 template<class TFixedImage, class TMovingImage, class TVirtualImage = TFixedImage>
99  public ImageToImageMetricv4< TFixedImage, TMovingImage, TVirtualImage>
100 {
101 public:
102 
108 
110  itkNewMacro(Self);
111 
113  itkTypeMacro(Self, Superclass);
114 
116  typedef typename Superclass::MeasureType MeasureType;
117  typedef typename Superclass::DerivativeType DerivativeType;
118  typedef typename Superclass::DerivativeValueType DerivativeValueType;
119  typedef typename Superclass::VirtualPointType VirtualPointType;
120  typedef typename Superclass::FixedImagePointType FixedImagePointType;
121  typedef typename Superclass::FixedImagePixelType FixedImagePixelType;
122  typedef typename Superclass::FixedTransformType FixedTransformType;
123  typedef typename Superclass::FixedImageGradientType FixedImageGradientType;
124  typedef typename FixedTransformType::JacobianType FixedImageJacobianType;
125 
126  typedef typename Superclass::MovingImagePointType MovingImagePointType;
127  typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
128  typedef typename Superclass::MovingImageGradientType MovingImageGradientType;
129  typedef typename Superclass::MovingTransformType MovingTransformType;
130  typedef typename MovingTransformType::JacobianType MovingImageJacobianType;
131  typedef typename Superclass::JacobianType JacobianType;
132 
133  typedef typename Superclass::VirtualImageGradientType VirtualImageGradientType;
134 
138  typedef typename Superclass::FixedOutputPointType FixedOutputPointType;
139  typedef typename Superclass::MovingOutputPointType MovingOutputPointType;
140 
142 
143  typedef typename Superclass::FixedTransformType::JacobianType
145  typedef typename Superclass::MovingTransformType::JacobianType
147 
148  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
150 
151  typedef typename VirtualImageType::RegionType ImageRegionType;
152  typedef typename VirtualImageType::SizeType RadiusType;
153  typedef typename VirtualImageType::IndexType IndexType;
154 
155  /* Image dimension accessors */
156  itkStaticConstMacro(FixedImageDimension, ImageDimensionType,
158 
159  itkStaticConstMacro(MovingImageDimension, ImageDimensionType,
161 
162  itkStaticConstMacro(VirtualImageDimension, ImageDimensionType,
164 
165  // Set the radius of the neighborhood window centered at each pixel.
166  // See the note above about using a radius less than 2.
167  itkSetMacro(Radius, RadiusType);
168 
169  // Get the Radius of the neighborhood window centered at each pixel
170  itkGetMacro(Radius, RadiusType);
171  itkGetConstMacro(Radius, RadiusType);
172 
173  void Initialize(void) throw ( itk::ExceptionObject );
174 
175 
176 protected:
178  virtual ~ANTSNeighborhoodCorrelationImageToImageMetricv4();
179 
180  // interested values here updated during scanning
182  typedef std::deque<QueueRealType> SumQueueType;
184 
185  // one ScanMemType for each thread
186  typedef struct ScanMemType {
187  // queues used in the scanning
188  // sum of the fixed value squared
189  SumQueueType QsumFixed2;
190  // sum of the moving value squared
191  SumQueueType QsumMoving2;
192  SumQueueType QsumFixed;
193  SumQueueType QsumMoving;
194  SumQueueType QsumFixedMoving;
195  SumQueueType Qcount;
196 
197  QueueRealType fixedA;
198  QueueRealType movingA;
199  QueueRealType sFixedMoving;
200  QueueRealType sFixedFixed;
201  QueueRealType sMovingMoving;
202 
205 
209  } ScanMemType;
210 
211  typedef struct ScanParametersType {
212  // const values during scanning
214  SizeValueType numberOfFillZero; // for each queue
215  SizeValueType windowLength; // number of voxels in the scanning window
217 
218  typename FixedImageType::ConstPointer fixedImage;
219  typename MovingImageType::ConstPointer movingImage;
220  typename VirtualImageType::ConstPointer virtualImage;
222 
224 
228 
230  void InitializeScanning(const ImageRegionType &scanRegion,
231  ScanIteratorType &scanIt, ScanMemType &scanMem,
232  ScanParametersType &scanParameters ) const;
233 
234  virtual void PrintSelf(std::ostream & os, Indent indent) const;
235 
236 private:
237  ANTSNeighborhoodCorrelationImageToImageMetricv4( const Self & ); //purposely not implemented
238  void operator=(const Self &); //purposely not implemented
239 
240  // Radius of the neighborhood window centered at each pixel
242 };
243 
244 } // end namespace itk
245 
246 #ifndef ITK_MANUAL_INSTANTIATION
247 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4.hxx"
248 #endif
249 
250 #endif
251