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 __itkBSplineScatteredDataPointSetToImageFilter_h 00019 #define __itkBSplineScatteredDataPointSetToImageFilter_h 00020 00021 #include "itkPointSetToImageFilter.h" 00022 00023 #include "itkBSplineKernelFunction.h" 00024 #include "itkCoxDeBoorBSplineKernelFunction.h" 00025 #include "itkVectorContainer.h" 00026 00027 #include "vnl/vnl_matrix.h" 00028 00029 namespace itk 00030 { 00128 template< class TInputPointSet, class TOutputImage > 00129 class BSplineScatteredDataPointSetToImageFilter: 00130 public PointSetToImageFilter< TInputPointSet, TOutputImage > 00131 { 00132 public: 00133 typedef BSplineScatteredDataPointSetToImageFilter Self; 00134 typedef PointSetToImageFilter<TInputPointSet, TOutputImage> Superclass; 00135 typedef SmartPointer<Self> Pointer; 00136 typedef SmartPointer<const Self> ConstPointer; 00137 00139 itkNewMacro( Self ); 00140 00142 itkStaticConstMacro( ImageDimension, unsigned int, 00143 TOutputImage::ImageDimension ); 00144 00145 typedef TOutputImage ImageType; 00146 typedef TInputPointSet PointSetType; 00147 00149 typedef typename ImageType::PixelType PixelType; 00150 typedef typename ImageType::RegionType RegionType; 00151 typedef typename ImageType::SizeType SizeType; 00152 typedef typename ImageType::IndexType IndexType; 00153 00155 typedef typename PointSetType::PointType PointType; 00156 typedef typename PointSetType::Pointer PointSetPointer; 00157 typedef typename PointSetType::PixelType PointDataType; 00158 typedef typename PointSetType::PointDataContainer PointDataContainerType; 00159 00161 typedef float RealType; 00162 typedef VectorContainer<unsigned, RealType> WeightsContainerType; 00163 00165 typedef Image<PointDataType, 00166 itkGetStaticConstMacro( ImageDimension )> PointDataImageType; 00167 typedef Image<RealType, 00168 itkGetStaticConstMacro( ImageDimension )> RealImageType; 00169 typedef typename RealImageType::Pointer RealImagePointer; 00170 typedef typename PointDataImageType::Pointer PointDataImagePointer; 00171 typedef FixedArray<unsigned, 00172 itkGetStaticConstMacro( ImageDimension )> ArrayType; 00174 00178 typedef CoxDeBoorBSplineKernelFunction<3> KernelType; 00179 typedef BSplineKernelFunction<0> KernelOrder0Type; 00180 typedef BSplineKernelFunction<1> KernelOrder1Type; 00181 typedef BSplineKernelFunction<2> KernelOrder2Type; 00182 typedef BSplineKernelFunction<3> KernelOrder3Type; 00183 00184 // Helper functions 00185 00192 void SetSplineOrder( unsigned int ); 00193 00199 void SetSplineOrder( const ArrayType & ); 00200 00206 itkGetConstReferenceMacro( SplineOrder, ArrayType ); 00207 00213 itkSetMacro( NumberOfControlPoints, ArrayType ); 00214 00220 itkGetConstReferenceMacro( NumberOfControlPoints, ArrayType ); 00221 00227 itkGetConstReferenceMacro( CurrentNumberOfControlPoints, ArrayType ); 00228 00235 void SetNumberOfLevels( unsigned int ); 00236 00243 void SetNumberOfLevels( const ArrayType & ); 00244 00251 itkGetConstReferenceMacro( NumberOfLevels, ArrayType ); 00252 00269 itkSetMacro( CloseDimension, ArrayType ); 00270 00287 itkGetConstReferenceMacro( CloseDimension, ArrayType ); 00288 00293 void SetPointWeights( WeightsContainerType *weights ); 00294 00300 itkSetMacro( GenerateOutputImage, bool ); 00301 00307 itkGetConstReferenceMacro( GenerateOutputImage, bool ); 00308 00314 itkBooleanMacro( GenerateOutputImage ); 00315 00319 itkGetConstMacro( PhiLattice, PointDataImagePointer ); 00320 00321 protected: 00322 BSplineScatteredDataPointSetToImageFilter(); 00323 virtual ~BSplineScatteredDataPointSetToImageFilter(); 00324 00325 void PrintSelf(std::ostream & os, Indent indent) const; 00326 00327 void ThreadedGenerateData( const RegionType &, ThreadIdType ); 00328 00329 void BeforeThreadedGenerateData(); 00330 00331 void AfterThreadedGenerateData(); 00332 00333 unsigned int SplitRequestedRegion( unsigned int, unsigned int, RegionType & ); 00334 00335 void GenerateData(); 00336 00337 private: 00338 00339 //purposely not implemented 00340 BSplineScatteredDataPointSetToImageFilter( const Self & ); 00341 void operator=( const Self & ); 00342 00347 void RefineControlPointLattice(); 00348 00352 void UpdatePointSet(); 00353 00358 void GenerateOutputImage(); 00359 00363 void ThreadedGenerateDataForFitting( const RegionType &, ThreadIdType ); 00364 00368 void ThreadedGenerateDataForReconstruction( const RegionType &, ThreadIdType ); 00369 00374 void CollapsePhiLattice( PointDataImageType *, PointDataImageType *, 00375 const RealType, const unsigned int ); 00376 00381 void SetPhiLatticeParametricDomainParameters(); 00382 00387 IndexType NumberToIndex( const unsigned int, const SizeType ); 00388 00389 bool m_DoMultilevel; 00390 bool m_GenerateOutputImage; 00391 bool m_UsePointWeights; 00392 unsigned int m_MaximumNumberOfLevels; 00393 unsigned int m_CurrentLevel; 00394 ArrayType m_NumberOfControlPoints; 00395 ArrayType m_CurrentNumberOfControlPoints; 00396 ArrayType m_CloseDimension; 00397 ArrayType m_SplineOrder; 00398 ArrayType m_NumberOfLevels; 00399 00400 typename WeightsContainerType::Pointer m_PointWeights; 00401 00402 typename PointDataImageType::Pointer m_PhiLattice; 00403 typename PointDataImageType::Pointer m_PsiLattice; 00404 00405 vnl_matrix<RealType> m_RefinedLatticeCoefficients[ImageDimension]; 00406 00407 typename PointDataContainerType::Pointer m_InputPointData; 00408 typename PointDataContainerType::Pointer m_OutputPointData; 00409 00410 typename KernelType::Pointer m_Kernel[ImageDimension]; 00411 00412 typename KernelOrder0Type::Pointer m_KernelOrder0; 00413 typename KernelOrder1Type::Pointer m_KernelOrder1; 00414 typename KernelOrder2Type::Pointer m_KernelOrder2; 00415 typename KernelOrder3Type::Pointer m_KernelOrder3; 00416 00417 std::vector<RealImagePointer> m_OmegaLatticePerThread; 00418 std::vector<PointDataImagePointer> m_DeltaLatticePerThread; 00419 00420 RealType m_BSplineEpsilon; 00421 bool m_IsFittingComplete; 00422 }; 00423 } // end namespace itk 00424 00425 #ifndef ITK_MANUAL_INSTANTIATION 00426 #include "itkBSplineScatteredDataPointSetToImageFilter.hxx" 00427 #endif 00428 00429 #endif 00430