ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkOrthogonalSwath2DPathFilter.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 __itkOrthogonalSwath2DPathFilter_h
00019 #define __itkOrthogonalSwath2DPathFilter_h
00020 
00021 #include "itkPathAndImageToPathFilter.h"
00022 #include "itkOrthogonallyCorrected2DParametricPath.h"
00023 
00024 namespace itk
00025 {
00051 template< class TFourierSeriesPath, class TSwathMeritImage >
00052 class ITK_EXPORT OrthogonalSwath2DPathFilter:public
00053   PathAndImageToPathFilter< TFourierSeriesPath, TSwathMeritImage,
00054                             OrthogonallyCorrected2DParametricPath >
00055 {
00056 public:
00058   typedef OrthogonalSwath2DPathFilter Self;
00059   typedef PathAndImageToPathFilter< TFourierSeriesPath, TSwathMeritImage,
00060                                     OrthogonallyCorrected2DParametricPath > Superclass;
00061   typedef SmartPointer< Self >       Pointer;
00062   typedef SmartPointer< const Self > ConstPointer;
00063 
00065   itkNewMacro(Self);
00066 
00068   itkTypeMacro(OrthogonalSwath2DPathFilter, PathAndImageToPathFilter);
00069 
00071   typedef TFourierSeriesPath                InputPathType;
00072   typedef typename InputPathType::Pointer   InputPathPointer;
00073   typedef typename InputPathType::InputType InputPathInputType;
00074 
00075   typedef TSwathMeritImage                 ImageType;
00076   typedef typename ImageType::ConstPointer ImageConstPointer;
00077 
00078   typedef OrthogonallyCorrected2DParametricPath OutputPathType;
00079   typedef typename OutputPathType::Pointer      OutputPathPointer;
00080   typedef typename OutputPathType::InputType    OutputPathInputType;
00081   typedef typename OutputPathType::OrthogonalCorrectionTableType
00082   OrthogonalCorrectionTableType;
00083   typedef typename OutputPathType::OrthogonalCorrectionTablePointer
00084   OrthogonalCorrectionTablePointer;
00085 
00086   typedef typename InputPathType::IndexType  IndexType;
00087   typedef typename InputPathType::OffsetType OffsetType;
00088   typedef typename ImageType::SizeType       SizeType;
00089 protected:
00090   OrthogonalSwath2DPathFilter();
00091   virtual ~OrthogonalSwath2DPathFilter();
00092   void PrintSelf(std::ostream & os, Indent indent) const;
00093 
00094   void GenerateData(void);
00095 
00096 private:
00097   OrthogonalSwath2DPathFilter(const Self &); //purposely not implemented
00098   void operator=(const Self &);              //purposely not implemented
00099 
00100   // Find the "L" for the maximum merit over the range L-1 to L+1 at F & x.
00101   // This value is both returned and stored in m_StepValues.
00102   // The merits for F & x at L-1 to L+1 must have already been calculated.
00103   unsigned int FindAndStoreBestErrorStep(unsigned int x, unsigned int F,
00104                                          unsigned int L);
00105 
00106   // m_StepValues & m_MeritValues are stored as datatype[x][F][L] which requres
00107   // cols*rows*rows bytes of storage where rows and cols are the dimensions of
00108   // the processed image.
00109   //
00110   // This ordering of elements is most efficient when L is incremented in the
00111   // inner-most loop and x is incremented in the outer-most loop.
00112   //
00113   // m_StepValues & m_MeritValues should always be accessed using the
00114   // StepValue()
00115   // and MeritValue() access functions.  StepValue() and MeritValue() can each
00116   // be
00117   // used on both the left and right hand of assignments for reads & writes, ex:
00118   // StepValue(1,1,1) = 2+MeritValue(0,0,3);
00119   inline int & StepValue(int f, int l, int x)
00120   {
00121     int rows = m_SwathSize[1];
00122 
00123     return m_StepValues[( x * rows * rows ) + ( f * rows ) + ( l )];
00124   }
00125 
00126   inline double & MeritValue(int f, int l, int x)
00127   {
00128     int rows = m_SwathSize[1];
00129 
00130     return m_MeritValues[( x * rows * rows ) + ( f * rows ) + ( l )];
00131   }
00132 
00133   int *   m_StepValues; // best y=error coordinate @ x of image for (0,F) ->
00134                         // (x+1,L)
00135   double *m_MeritValues;
00136 
00137   int *                            m_OptimumStepsValues;  // best step (e value)
00138                                                           // sequence for a
00139                                                           // closed path
00140   OrthogonalCorrectionTablePointer m_FinalOffsetValues;
00141 
00142   SizeType m_SwathSize;
00143 };
00144 } // end namespace itk
00145 
00146 #ifndef ITK_MANUAL_INSTANTIATION
00147 #include "itkOrthogonalSwath2DPathFilter.hxx"
00148 #endif
00149 
00150 #endif
00151