ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkANTSNeighborhoodCorrelationImageToImageMetricv4_h 00019 #define __itkANTSNeighborhoodCorrelationImageToImageMetricv4_h 00020 00021 #include "itkImageToImageMetricv4.h" 00022 #include "itkConstNeighborhoodIterator.h" 00023 00024 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4DenseGetValueAndDerivativeThreader.h" 00025 00026 #include <deque> 00027 00028 namespace itk { 00029 00091 template<class TFixedImage, class TMovingImage, class TVirtualImage = TFixedImage> 00092 class ITK_EXPORT ANTSNeighborhoodCorrelationImageToImageMetricv4 : 00093 public ImageToImageMetricv4< TFixedImage, TMovingImage, TVirtualImage> 00094 { 00095 public: 00096 00098 typedef ANTSNeighborhoodCorrelationImageToImageMetricv4 Self; 00099 typedef ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage> Superclass; 00100 typedef SmartPointer<Self> Pointer; 00101 typedef SmartPointer<const Self> ConstPointer; 00102 00104 itkNewMacro(Self); 00105 00107 itkTypeMacro(Self, Superclass); 00108 00110 typedef typename Superclass::MeasureType MeasureType; 00111 typedef typename Superclass::DerivativeType DerivativeType; 00112 typedef typename Superclass::DerivativeValueType DerivativeValueType; 00113 typedef typename Superclass::VirtualPointType VirtualPointType; 00114 typedef typename Superclass::FixedImagePointType FixedImagePointType; 00115 typedef typename Superclass::FixedImagePixelType FixedImagePixelType; 00116 typedef typename Superclass::FixedTransformType FixedTransformType; 00117 typedef typename Superclass::FixedImageGradientType FixedImageGradientType; 00118 typedef typename FixedTransformType::JacobianType FixedImageJacobianType; 00119 00120 typedef typename Superclass::MovingImagePointType MovingImagePointType; 00121 typedef typename Superclass::MovingImagePixelType MovingImagePixelType; 00122 typedef typename Superclass::MovingImageGradientType MovingImageGradientType; 00123 typedef typename Superclass::MovingTransformType MovingTransformType; 00124 typedef typename MovingTransformType::JacobianType MovingImageJacobianType; 00125 typedef typename Superclass::JacobianType JacobianType; 00126 00127 typedef typename Superclass::VirtualImageGradientType VirtualImageGradientType; 00128 00129 typedef typename Superclass::FixedImageType FixedImageType; 00130 typedef typename Superclass::MovingImageType MovingImageType; 00131 typedef typename Superclass::VirtualImageType VirtualImageType; 00132 typedef typename Superclass::FixedOutputPointType FixedOutputPointType; 00133 typedef typename Superclass::MovingOutputPointType MovingOutputPointType; 00134 00135 typedef typename Superclass::InternalComputationValueType InternalComputationValueType; 00136 00137 typedef typename Superclass::FixedTransformType::JacobianType 00138 FixedTransformJacobianType; 00139 typedef typename Superclass::MovingTransformType::JacobianType 00140 MovingTransformJacobianType; 00141 00142 typedef typename Superclass::NumberOfParametersType NumberOfParametersType; 00143 typedef typename Superclass::ImageDimensionType ImageDimensionType; 00144 00145 typedef typename VirtualImageType::RegionType ImageRegionType; 00146 typedef typename VirtualImageType::SizeType RadiusType; 00147 typedef typename VirtualImageType::IndexType IndexType; 00148 00149 /* Image dimension accessors */ 00150 itkStaticConstMacro(FixedImageDimension, ImageDimensionType, 00151 ::itk::GetImageDimension<FixedImageType>::ImageDimension); 00152 00153 itkStaticConstMacro(MovingImageDimension, ImageDimensionType, 00154 ::itk::GetImageDimension<MovingImageType>::ImageDimension); 00155 00156 itkStaticConstMacro(VirtualImageDimension, ImageDimensionType, 00157 ::itk::GetImageDimension<VirtualImageType>::ImageDimension); 00158 00159 // Set the radius of the neighborhood window centered at each pixel 00160 itkSetMacro(Radius, RadiusType); 00161 00162 // Get the Radius of the neighborhood window centered at each pixel 00163 itkGetMacro(Radius, RadiusType); 00164 itkGetConstMacro(Radius, RadiusType); 00165 00166 protected: 00167 ANTSNeighborhoodCorrelationImageToImageMetricv4(); 00168 virtual ~ANTSNeighborhoodCorrelationImageToImageMetricv4(); 00169 00170 // interested values here updated during scanning 00171 typedef InternalComputationValueType QueueRealType; 00172 typedef std::deque<QueueRealType> SumQueueType; 00173 typedef ConstNeighborhoodIterator<VirtualImageType> ScanIteratorType; 00174 00175 // one ScanMemType for each thread 00176 typedef struct ScanMemType { 00177 // queues used in the scanning 00178 // sum of the fixed value squared 00179 SumQueueType QsumFixed2; 00180 // sum of the moving value squared 00181 SumQueueType QsumMoving2; 00182 SumQueueType QsumFixed; 00183 SumQueueType QsumMoving; 00184 SumQueueType QsumFixedMoving; 00185 SumQueueType Qcount; 00186 00187 QueueRealType fixedA; 00188 QueueRealType movingA; 00189 QueueRealType sFixedMoving; 00190 QueueRealType sFixedFixed; 00191 QueueRealType sMovingMoving; 00192 00193 FixedImageGradientType fixedImageGradient; 00194 MovingImageGradientType movingImageGradient; 00195 00196 FixedImagePointType mappedFixedPoint; 00197 MovingImagePointType mappedMovingPoint; 00198 VirtualPointType virtualPoint; 00199 } ScanMemType; 00200 00201 typedef struct ScanParametersType { 00202 // const values during scanning 00203 ImageRegionType scanRegion; 00204 SizeValueType numberOfFillZero; // for each queue 00205 SizeValueType windowLength; // number of voxels in the scanning window 00206 IndexValueType scanRegionBeginIndexDim0; 00207 00208 typename FixedImageType::ConstPointer fixedImage; 00209 typename MovingImageType::ConstPointer movingImage; 00210 typename VirtualImageType::ConstPointer virtualImage; 00211 RadiusType radius; 00212 00213 } ScanParametersType; 00214 00215 friend class ANTSNeighborhoodCorrelationImageToImageMetricv4DenseGetValueAndDerivativeThreader< Superclass, Self >; 00216 typedef ANTSNeighborhoodCorrelationImageToImageMetricv4DenseGetValueAndDerivativeThreader< Superclass, Self > 00217 ANTSNeighborhoodCorrelationImageToImageMetricv4DenseGetValueAndDerivativeThreaderType; 00218 00220 void InitializeScanning(const ImageRegionType &scanRegion, 00221 ScanIteratorType &scanIt, ScanMemType &scanMem, 00222 ScanParametersType &scanParameters ) const; 00223 00224 virtual void PrintSelf(std::ostream & os, Indent indent) const; 00225 00226 private: 00227 ANTSNeighborhoodCorrelationImageToImageMetricv4( const Self & ); //purposely not implemented 00228 void operator=(const Self &); //purposely not implemented 00229 00230 // Radius of the neighborhood window centered at each pixel 00231 RadiusType m_Radius; 00232 }; 00233 00234 } // end namespace itk 00235 00236 #ifndef ITK_MANUAL_INSTANTIATION 00237 #include "itkANTSNeighborhoodCorrelationImageToImageMetricv4.hxx" 00238 #endif 00239 00240 #endif 00241