ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkShapePriorSegmentationLevelSetImageFilter.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 #ifndef __itkShapePriorSegmentationLevelSetImageFilter_h
00019 #define __itkShapePriorSegmentationLevelSetImageFilter_h
00020 
00021 #include "itkSegmentationLevelSetImageFilter.h"
00022 #include "itkShapePriorSegmentationLevelSetFunction.h"
00023 #include "itkSingleValuedNonLinearOptimizer.h"
00024 #include "itkShapePriorMAPCostFunctionBase.h"
00025 
00026 namespace itk
00027 {
00071 template< class TInputImage,
00072           class TFeatureImage,
00073           class TOutputPixelType = float >
00074 class ITK_EXPORT ShapePriorSegmentationLevelSetImageFilter:
00075   public SegmentationLevelSetImageFilter< TInputImage, TFeatureImage,
00076                                           TOutputPixelType >
00077 {
00078 public:
00079 
00081   itkStaticConstMacro(ImageDimension, unsigned int,
00082                       TInputImage::ImageDimension);
00083 
00085   typedef ShapePriorSegmentationLevelSetImageFilter Self;
00086   typedef SegmentationLevelSetImageFilter< TInputImage, TFeatureImage, TOutputPixelType >
00087   Superclass;
00088   typedef SmartPointer< Self >       Pointer;
00089   typedef SmartPointer< const Self > ConstPointer;
00090 
00092   itkTypeMacro(ShapePriorSegmentationLevelSetImageFilter, SegmentationLevelSetImageFilter);
00093 
00095   typedef typename Superclass::ValueType        ValueType;
00096   typedef typename Superclass::OutputImageType  OutputImageType;
00097   typedef typename Superclass::FeatureImageType FeatureImageType;
00098 
00100   typedef TOutputPixelType OutputPixelType;
00101 
00103   typedef ShapePriorSegmentationLevelSetFunction< OutputImageType,
00104                                                   FeatureImageType > ShapePriorSegmentationFunctionType;
00105 
00107   typedef typename ShapePriorSegmentationFunctionType::ShapeFunctionType ShapeFunctionType;
00108   typedef typename ShapeFunctionType::Pointer                            ShapeFunctionPointer;
00109 
00111   typedef  ShapePriorMAPCostFunctionBase< TFeatureImage, TOutputPixelType > CostFunctionType;
00112   typedef  typename CostFunctionType::Pointer                               CostFunctionPointer;
00113   typedef  typename CostFunctionType::ParametersType                        ParametersType;
00114 
00116   typedef  typename CostFunctionType::NodeType          NodeType;
00117   typedef  typename CostFunctionType::NodeContainerType NodeContainerType;
00118   typedef  typename NodeContainerType::Pointer          NodeContainerPointer;
00119 
00122   typedef   SingleValuedNonLinearOptimizer  OptimizerType;
00123   typedef   typename OptimizerType::Pointer OptimizerPointer;
00124 
00126   virtual void SetShapeFunction(ShapeFunctionType *s);
00127 
00128   itkGetObjectMacro(ShapeFunction, ShapeFunctionType);
00129 
00131   itkSetObjectMacro(CostFunction, CostFunctionType);
00132   itkGetObjectMacro(CostFunction, CostFunctionType);
00134 
00136   itkSetObjectMacro(Optimizer, OptimizerType);
00137   itkGetObjectMacro(Optimizer, OptimizerType);
00139 
00144   itkSetMacro(InitialParameters, ParametersType);
00145   itkGetConstMacro(InitialParameters, ParametersType);
00147 
00149   void SetShapePriorScaling(ValueType v)
00150   {
00151     if ( v != m_ShapePriorSegmentationFunction->GetShapePriorWeight() )
00152       {
00153       m_ShapePriorSegmentationFunction->SetShapePriorWeight(v);
00154       this->Modified();
00155       }
00156   }
00158 
00159   ValueType GetShapePriorScaling() const
00160   {
00161     return m_ShapePriorSegmentationFunction->GetShapePriorWeight();
00162   }
00163 
00166   virtual void SetShapePriorSegmentationFunction(ShapePriorSegmentationFunctionType *s);
00167 
00168   virtual ShapePriorSegmentationFunctionType * GetShapePriorSegmentationFunction()
00169   { return m_ShapePriorSegmentationFunction; }
00170 
00172   itkGetConstReferenceMacro(CurrentParameters, ParametersType);
00173 protected:
00174   virtual ~ShapePriorSegmentationLevelSetImageFilter() {}
00175   ShapePriorSegmentationLevelSetImageFilter();
00177 
00178   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00179 
00182   virtual void InitializeIteration();
00183 
00186   void GenerateData();
00187 
00189   void ExtractActiveRegion(NodeContainerType *ptr);
00190 
00191 private:
00192   ShapePriorSegmentationLevelSetImageFilter(const Self &); //purposely not
00193                                                            // implemented
00194   void operator=(const Self &);                            //purposely not
00195 
00196   // implemented
00197 
00198   ShapeFunctionPointer m_ShapeFunction;
00199   CostFunctionPointer  m_CostFunction;
00200   OptimizerPointer     m_Optimizer;
00201   ParametersType       m_InitialParameters;
00202   ParametersType       m_CurrentParameters;
00203 
00204   ShapePriorSegmentationFunctionType *m_ShapePriorSegmentationFunction;
00205 };
00206 } // end namespace itk
00207 
00208 #ifndef ITK_MANUAL_INSTANTIATION
00209 #include "itkShapePriorSegmentationLevelSetImageFilter.hxx"
00210 #endif
00211 
00212 #endif
00213