ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkBinaryImageToLevelSetImageAdaptor.h
Go to the documentation of this file.
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 
00019 #ifndef __itkBinaryImageToLevelSetImageAdaptor_h
00020 #define __itkBinaryImageToLevelSetImageAdaptor_h
00021 
00022 #include "itkBinaryImageToLevelSetImageAdaptorBase.h"
00023 
00024 #include "itkLevelSetDenseImageBase.h"
00025 #include "itkImageToImageFilter.h"
00026 
00027 #include "itkWhitakerSparseLevelSetImage.h"
00028 #include "itkImageRegionIteratorWithIndex.h"
00029 #include "itkShapedNeighborhoodIterator.h"
00030 
00031 #include "itkShiSparseLevelSetImage.h"
00032 #include "itkMalcolmSparseLevelSetImage.h"
00033 
00034 namespace itk
00035 {
00036 template< class TInputImage, class TLevelSet >
00037 class BinaryImageToLevelSetImageAdaptor
00038 {};
00039 
00040 
00044 template< class TInputImage, class TLevelSetImage >
00045 class BinaryImageToLevelSetImageAdaptor<
00046     TInputImage,
00047     LevelSetDenseImageBase< TLevelSetImage > > :
00048 public BinaryImageToLevelSetImageAdaptorBase<
00049     TInputImage,
00050     LevelSetDenseImageBase< TLevelSetImage > >
00051 {
00052 public:
00053   typedef LevelSetDenseImageBase< TLevelSetImage >  LevelSetType;
00054 
00055   typedef BinaryImageToLevelSetImageAdaptor         Self;
00056   typedef SmartPointer< Self >                      Pointer;
00057   typedef SmartPointer< const Self >                ConstPointer;
00058   typedef BinaryImageToLevelSetImageAdaptorBase<
00059     TInputImage, LevelSetType >                     Superclass;
00060 
00062   itkNewMacro( Self );
00063 
00065   itkTypeMacro( BinaryImageToLevelSetImageAdaptorBase, Object );
00066 
00067   typedef TInputImage                           InputImageType;
00068   typedef typename InputImageType::PixelType    InputImagePixelType;
00069   typedef typename InputImageType::IndexType    InputImageIndexType;
00070   typedef typename InputImageType::Pointer      InputImagePointer;
00071   typedef typename InputImageType::RegionType   InputImageRegionType;
00072   typedef typename NumericTraits< InputImagePixelType >::RealType
00073                                                 InputPixelRealType;
00074 
00075   itkStaticConstMacro ( ImageDimension, unsigned int,
00076                        InputImageType::ImageDimension );
00077 
00078   typedef typename LevelSetType::Pointer    LevelSetPointer;
00079   typedef typename LevelSetType::ImageType  LevelSetImageType;
00080 
00081   typedef ImageToImageFilter< InputImageType, LevelSetImageType >  SignedDistanceTransformFilterType;
00082   typedef typename SignedDistanceTransformFilterType::Pointer      SignedDistanceTransformFilterPointer;
00083 
00086   itkSetObjectMacro( SignedDistanceTransformFilter, SignedDistanceTransformFilterType );
00087   itkGetObjectMacro( SignedDistanceTransformFilter, SignedDistanceTransformFilterType );
00089 
00093   void Initialize();
00094 
00095 protected:
00097   BinaryImageToLevelSetImageAdaptor();
00098 
00100   virtual ~BinaryImageToLevelSetImageAdaptor();
00101 
00102 private:
00103   BinaryImageToLevelSetImageAdaptor( const Self& ); // purposely not implemented
00104   void operator = ( const Self& ); // purposely not implemented
00105 
00106   SignedDistanceTransformFilterPointer   m_SignedDistanceTransformFilter;
00107 };
00108 
00110 
00111 template< class TInput, class TOutput >
00112 class BinaryImageToSparseLevelSetImageAdaptorBase :
00113     public BinaryImageToLevelSetImageAdaptorBase< TInput, TOutput >
00114 {
00115 public:
00116   typedef BinaryImageToSparseLevelSetImageAdaptorBase Self;
00117   typedef SmartPointer< Self >                        Pointer;
00118   typedef SmartPointer< const Self >                  ConstPointer;
00119   typedef BinaryImageToLevelSetImageAdaptorBase< TInput, TOutput >
00120     Superclass;
00121 
00123   itkTypeMacro( BinaryImageToSparseLevelSetImageAdaptorBase,
00124                 BinaryImageToLevelSetImageAdaptorBase );
00125 
00126   typedef typename Superclass::InputImageType       InputImageType;
00127   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00128   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00129   typedef typename Superclass::InputImagePointer    InputImagePointer;
00130   typedef typename Superclass::InputImageRegionType InputImageRegionType;
00131   typedef typename Superclass::InputPixelRealType   InputPixelRealType;
00132 
00133   itkStaticConstMacro ( ImageDimension, unsigned int,
00134                        InputImageType::ImageDimension );
00135 
00136   typedef typename Superclass::LevelSetType             LevelSetType;
00137   typedef typename Superclass::LevelSetPointer          LevelSetPointer;
00138 
00139   typedef typename LevelSetType::InputType              LevelSetInputType;
00140   typedef typename LevelSetType::OutputType             LevelSetOutputType;
00141 
00142   typedef typename LevelSetType::LabelObjectType        LevelSetLabelObjectType;
00143   typedef typename LevelSetLabelObjectType::LabelType   LayerIdType;
00144   typedef typename LevelSetType::LabelObjectPointer     LevelSetLabelObjectPointer;
00145   typedef typename LevelSetType::LabelObjectLengthType  LevelSetLabelObjectLengthType;
00146   typedef typename LevelSetType::LabelObjectLineType    LevelSetLabelObjectLineType;
00147 
00148   typedef typename LevelSetType::LabelMapType           LevelSetLabelMapType;
00149   typedef typename LevelSetType::LabelMapPointer        LevelSetLabelMapPointer;
00150 
00151   typedef typename LevelSetType::LayerType              LevelSetLayerType;
00152   typedef typename LevelSetType::LayerIterator          LevelSetLayerIterator;
00153   typedef typename LevelSetType::LayerConstIterator     LevelSetLayerConstIterator;
00154 
00155   typedef Image< char, ImageDimension >         InternalImageType;
00156   typedef typename InternalImageType::Pointer   InternalImagePointer;
00157 
00158   typedef std::pair< LevelSetInputType, LevelSetOutputType >  LayerPairType;
00159 
00160   typedef ImageRegionIteratorWithIndex< InputImageType >      InputIteratorType;
00161   typedef ImageRegionIteratorWithIndex< InternalImageType >   InternalIteratorType;
00162 
00163   typedef ShapedNeighborhoodIterator< InternalImageType > NeighborhoodIteratorType;
00164 
00165 protected:
00166   BinaryImageToSparseLevelSetImageAdaptorBase() : Superclass() {}
00167   virtual ~BinaryImageToSparseLevelSetImageAdaptorBase() {}
00168 
00169   LevelSetLabelMapPointer m_LabelMap;
00170 
00171   InternalImagePointer m_InternalImage;
00172 
00173 private:
00174   BinaryImageToSparseLevelSetImageAdaptorBase( const Self& );
00175   void operator = ( const Self& );
00176 };
00177 
00179 template< class TInput, typename TOutput >
00180 class BinaryImageToLevelSetImageAdaptor<
00181     TInput,
00182     WhitakerSparseLevelSetImage< TOutput, TInput::ImageDimension > > :
00183   public BinaryImageToSparseLevelSetImageAdaptorBase<
00184       TInput,
00185       WhitakerSparseLevelSetImage< TOutput, TInput::ImageDimension > >
00186   {
00187 public:
00188   typedef WhitakerSparseLevelSetImage< TOutput, TInput::ImageDimension >
00189     LevelSetType;
00190 
00191   typedef BinaryImageToLevelSetImageAdaptor       Self;
00192   typedef SmartPointer< Self >                    Pointer;
00193   typedef SmartPointer< const Self >              ConstPointer;
00194   typedef BinaryImageToSparseLevelSetImageAdaptorBase<
00195     TInput, LevelSetType >                        Superclass;
00196 
00197 
00199   itkNewMacro( Self );
00200 
00202   itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
00203                 BinaryImageToSparseLevelSetImageAdaptorBase );
00204 
00205   typedef typename Superclass::InputImageType       InputImageType;
00206   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00207   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00208   typedef typename Superclass::InputImagePointer    InputImagePointer;
00209   typedef typename Superclass::InputImageRegionType InputImageRegionType;
00210   typedef typename Superclass::InputPixelRealType   InputPixelRealType;
00211 
00212   itkStaticConstMacro ( ImageDimension, unsigned int,
00213                         InputImageType::ImageDimension );
00214 
00215   typedef typename Superclass::LevelSetPointer                LevelSetPointer;
00216 
00217   typedef typename Superclass::LevelSetInputType              LevelSetInputType;
00218   typedef typename Superclass::LevelSetOutputType             LevelSetOutputType;
00219 
00220   typedef typename Superclass::LevelSetLabelObjectType        LevelSetLabelObjectType;
00221   typedef typename Superclass::LayerIdType                    LayerIdType;
00222   typedef typename Superclass::LevelSetLabelObjectPointer     LevelSetLabelObjectPointer;
00223   typedef typename Superclass::LevelSetLabelObjectLengthType  LevelSetLabelObjectLengthType;
00224   typedef typename Superclass::LevelSetLabelObjectLineType    LevelSetLabelObjectLineType;
00225 
00226   typedef typename Superclass::LevelSetLabelMapType           LevelSetLabelMapType;
00227   typedef typename Superclass::LevelSetLabelMapPointer        LevelSetLabelMapPointer;
00228 
00229   typedef typename Superclass::LevelSetLayerType              LevelSetLayerType;
00230   typedef typename Superclass::LevelSetLayerIterator          LevelSetLayerIterator;
00231   typedef typename Superclass::LevelSetLayerConstIterator     LevelSetLayerConstIterator;
00232 
00233   typedef typename Superclass::InternalImageType        InternalImageType;
00234   typedef typename Superclass::InternalImagePointer     InternalImagePointer;
00235 
00236   typedef typename Superclass::LayerPairType            LayerPairType;
00237 
00238   typedef typename Superclass::InputIteratorType        InputIteratorType;
00239   typedef typename Superclass::InternalIteratorType     InternalIteratorType;
00240 
00241   typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
00242 
00243   void Initialize();
00244 
00245 protected:
00247   BinaryImageToLevelSetImageAdaptor();
00248 
00250   virtual ~BinaryImageToLevelSetImageAdaptor();
00251 
00252 private:
00253 
00254   BinaryImageToLevelSetImageAdaptor( const Self& ); // purposely not implemented
00255   void operator = ( const Self& );  // purposely not implemented
00256 
00258   void PropagateToOuterLayers( LayerIdType LayerToBeScanned, LayerIdType OutputLayer, LayerIdType TestValue );
00259 
00261   void FindActiveLayer();
00262 
00264   void FindPlusOneMinusOneLayer();
00265 
00266 };
00267 
00269 template< class TInput >
00270 class BinaryImageToLevelSetImageAdaptor<
00271     TInput,
00272     ShiSparseLevelSetImage< TInput::ImageDimension > > :
00273 public BinaryImageToSparseLevelSetImageAdaptorBase<
00274     TInput,
00275     ShiSparseLevelSetImage< TInput::ImageDimension > >
00276 {
00277 public:
00278   typedef ShiSparseLevelSetImage< TInput::ImageDimension > LevelSetType;
00279 
00280   typedef BinaryImageToLevelSetImageAdaptor       Self;
00281   typedef SmartPointer< Self >                    Pointer;
00282   typedef SmartPointer< const Self >              ConstPointer;
00283   typedef BinaryImageToSparseLevelSetImageAdaptorBase<
00284     TInput, LevelSetType >                        Superclass;
00285 
00287   itkNewMacro( Self );
00288 
00290   itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
00291                 BinaryImageToSparseLevelSetImageAdaptorBase );
00292 
00293   typedef typename Superclass::InputImageType       InputImageType;
00294 
00295   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00296   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00297   typedef typename Superclass::InputImagePointer    InputImagePointer;
00298   typedef typename Superclass::InputImageRegionType InputImageRegionType;
00299   typedef typename Superclass::InputPixelRealType   InputPixelRealType;
00300 
00301   itkStaticConstMacro ( ImageDimension, unsigned int,
00302                        InputImageType::ImageDimension );
00303 
00304 //  typedef typename Superclass::LevelSetType             LevelSetType;
00305   typedef typename Superclass::LevelSetPointer                LevelSetPointer;
00306 
00307   typedef typename Superclass::LevelSetInputType              LevelSetInputType;
00308   typedef typename Superclass::LevelSetOutputType             LevelSetOutputType;
00309 
00310   typedef typename Superclass::LevelSetLabelObjectType        LevelSetLabelObjectType;
00311   typedef typename Superclass::LayerIdType                    LayerIdType;
00312   typedef typename Superclass::LevelSetLabelObjectPointer     LevelSetLabelObjectPointer;
00313   typedef typename Superclass::LevelSetLabelObjectLengthType  LevelSetLabelObjectLengthType;
00314   typedef typename Superclass::LevelSetLabelObjectLineType    LevelSetLabelObjectLineType;
00315 
00316   typedef typename Superclass::LevelSetLabelMapType           LevelSetLabelMapType;
00317   typedef typename Superclass::LevelSetLabelMapPointer        LevelSetLabelMapPointer;
00318 
00319   typedef typename Superclass::LevelSetLayerType              LevelSetLayerType;
00320   typedef typename Superclass::LevelSetLayerIterator          LevelSetLayerIterator;
00321   typedef typename Superclass::LevelSetLayerConstIterator     LevelSetLayerConstIterator;
00322 
00323   typedef typename Superclass::InternalImageType        InternalImageType;
00324   typedef typename Superclass::InternalImagePointer     InternalImagePointer;
00325 
00326   typedef typename Superclass::LayerPairType            LayerPairType;
00327 
00328   typedef typename Superclass::InputIteratorType        InputIteratorType;
00329   typedef typename Superclass::InternalIteratorType     InternalIteratorType;
00330 
00331   typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
00332 
00333   void Initialize();
00334 
00335 protected:
00337   BinaryImageToLevelSetImageAdaptor();
00338 
00340   ~BinaryImageToLevelSetImageAdaptor();
00341 
00343   void FindActiveLayer();
00344 
00345 private:
00346 
00347   BinaryImageToLevelSetImageAdaptor( const Self& ); // purposely not implemented
00348   void operator = ( const Self& );  // purposely not implemented
00349 };
00350 
00351 
00353 template< class TInput >
00354 class BinaryImageToLevelSetImageAdaptor<
00355     TInput,
00356     MalcolmSparseLevelSetImage< TInput::ImageDimension > > :
00357   public BinaryImageToSparseLevelSetImageAdaptorBase< TInput, MalcolmSparseLevelSetImage< TInput::ImageDimension > >
00358 {
00359 public:
00360   typedef MalcolmSparseLevelSetImage< TInput::ImageDimension > LevelSetType;
00361 
00362   typedef BinaryImageToLevelSetImageAdaptor       Self;
00363   typedef SmartPointer< Self >                    Pointer;
00364   typedef SmartPointer< const Self >              ConstPointer;
00365   typedef BinaryImageToSparseLevelSetImageAdaptorBase<
00366     TInput, LevelSetType >                        Superclass;
00367 
00368 
00370   itkNewMacro( Self );
00371 
00373   itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
00374                 BinaryImageToSparseLevelSetImageAdaptorBase );
00375 
00376   typedef typename Superclass::InputImageType       InputImageType;
00377 
00378   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00379   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00380   typedef typename Superclass::InputImagePointer    InputImagePointer;
00381   typedef typename Superclass::InputImageRegionType InputImageRegionType;
00382   typedef typename Superclass::InputPixelRealType   InputPixelRealType;
00383 
00384   itkStaticConstMacro ( ImageDimension, unsigned int,
00385                        InputImageType::ImageDimension );
00386 
00387 
00388   typedef typename Superclass::LevelSetPointer                LevelSetPointer;
00389   typedef typename Superclass::LevelSetInputType              LevelSetInputType;
00390   typedef typename Superclass::LevelSetOutputType             LevelSetOutputType;
00391 
00392   typedef typename Superclass::LevelSetLabelObjectType        LevelSetLabelObjectType;
00393   typedef typename Superclass::LayerIdType                    LayerIdType;
00394   typedef typename Superclass::LevelSetLabelObjectPointer     LevelSetLabelObjectPointer;
00395   typedef typename Superclass::LevelSetLabelObjectLengthType  LevelSetLabelObjectLengthType;
00396   typedef typename Superclass::LevelSetLabelObjectLineType    LevelSetLabelObjectLineType;
00397 
00398   typedef typename Superclass::LevelSetLabelMapType           LevelSetLabelMapType;
00399   typedef typename Superclass::LevelSetLabelMapPointer        LevelSetLabelMapPointer;
00400 
00401   typedef typename Superclass::LevelSetLayerType              LevelSetLayerType;
00402   typedef typename Superclass::LevelSetLayerIterator          LevelSetLayerIterator;
00403   typedef typename Superclass::LevelSetLayerConstIterator     LevelSetLayerConstIterator;
00404 
00405   typedef typename Superclass::InternalImageType        InternalImageType;
00406   typedef typename Superclass::InternalImagePointer     InternalImagePointer;
00407 
00408   typedef typename Superclass::LayerPairType            LayerPairType;
00409 
00410   typedef typename Superclass::InputIteratorType        InputIteratorType;
00411   typedef typename Superclass::InternalIteratorType     InternalIteratorType;
00412 
00413   typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
00414 
00415   void Initialize();
00416 
00417 protected:
00419   BinaryImageToLevelSetImageAdaptor();
00420 
00422   virtual ~BinaryImageToLevelSetImageAdaptor();
00423 
00425   void FindActiveLayer();
00426 
00428   void CreateMinimalInterface();
00429 
00430 private:
00431 
00432   BinaryImageToLevelSetImageAdaptor( const Self& ); // purposely not implemented
00433   void operator = ( const Self& );  // purposely not implemented
00434 };
00435 
00436 }
00437 
00438 #ifndef ITK_MANUAL_INSTANTIATION
00439 #include "itkBinaryImageToLevelSetImageAdaptor.hxx"
00440 #endif
00441 #endif // __itkBinaryImageToLevelSetImageAdaptorBase_h
00442