ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkMirrorPadImageFilter.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 __itkMirrorPadImageFilter_h
00019 #define __itkMirrorPadImageFilter_h
00020 
00021 #include "itkPadImageFilter.h"
00022 #include <vector>
00023 
00024 namespace itk
00025 {
00051 template< class TInputImage, class TOutputImage >
00052 class ITK_EXPORT MirrorPadImageFilter:
00053   public PadImageFilter< TInputImage, TOutputImage >
00054 {
00055 public:
00057   typedef MirrorPadImageFilter                        Self;
00058   typedef PadImageFilter< TInputImage, TOutputImage > Superclass;
00059   typedef SmartPointer< Self >                        Pointer;
00060   typedef SmartPointer< const Self >                  ConstPointer;
00061 
00063   itkNewMacro(Self);
00064 
00066   itkTypeMacro(MirrorPadImageFilter, PadImageFilter);
00067 
00068   typedef TInputImage  InputImageType;
00069   typedef TOutputImage OutputImageType;
00070 
00072   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00073   typedef typename Superclass::InputImageRegionType  InputImageRegionType;
00074 
00076   typedef typename Superclass::OutputImagePixelType OutputImagePixelType;
00077   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00078 
00080   typedef typename Superclass::OutputImageIndexType OutputImageIndexType;
00081   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00082   typedef typename Superclass::OutputImageSizeType  OutputImageSizeType;
00083   typedef typename Superclass::InputImageSizeType   InputImageSizeType;
00084 
00086   itkStaticConstMacro(ImageDimension, unsigned int,
00087                       TInputImage::ImageDimension);
00088 
00089 #ifdef ITK_USE_CONCEPT_CHECKING
00090 
00091   itkConceptMacro( InputConvertibleToOutputCheck,
00092                    ( Concept::Convertible< InputImagePixelType, OutputImagePixelType > ) );
00093 
00095 #endif
00096 protected:
00097   MirrorPadImageFilter() {}
00098   ~MirrorPadImageFilter() {}
00100 
00103   void ConvertOutputIndexToInputIndex(OutputImageIndexType & outputIndex,
00104                                       InputImageIndexType & inputIndex,
00105                                       OutputImageRegionType & outputRegion,
00106                                       InputImageRegionType & inputRegion,
00107                                       int *oddRegionArray);
00108 
00111   int RegionIsOdd(long base, long test, long size);
00112 
00123   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00124                             ThreadIdType threadId);
00125 
00129   int GenerateNextInputRegion(long *regIndices, long *regLimit,
00130                               std::vector< long > *indices,
00131                               std::vector< long > *sizes,
00132                               InputImageRegionType & outputRegion);
00133 
00137   int GenerateNextOutputRegion(long *regIndices, long *regLimit,
00138                                std::vector< long > *indices,
00139                                std::vector< long > *sizes,
00140                                OutputImageRegionType & outputRegion);
00141 
00146   int FindRegionsInArea(long start, long end, long size, long offset);
00147 
00154   int BuildInterRegions(std::vector< long > & inputRegionStart,
00155                         std::vector< long > & outputRegionStart,
00156                         std::vector< long > & inputRegionSizes,
00157                         std::vector< long > & outputRegionSizes,
00158                         long inputIndex, long outputIndex,
00159                         long inputSize, long outputSize, int numRegs,
00160                         int & regCtr);
00161 
00170   int BuildPreRegions(std::vector< long > & inputRegionStart,
00171                       std::vector< long > & outputRegionStart,
00172                       std::vector< long > & inputRegionSizes,
00173                       std::vector< long > & outputRegionSizes,
00174                       long inputIndex, long outputIndex,
00175                       long inputSize, long outputSize, int numRegs,
00176                       int & regCtr);
00177 
00186   int BuildPostRegions(std::vector< long > & inputRegionStart,
00187                        std::vector< long > & outputRegionStart,
00188                        std::vector< long > & inputRegionSizes,
00189                        std::vector< long > & outputRegionSizes,
00190                        long inputIndex, long outputIndex,
00191                        long inputSize, long outputSize,
00192                        int numRegs, int & regCtr);
00193 
00201   virtual void GenerateInputRequestedRegion();
00202 
00203 private:
00204   MirrorPadImageFilter(const Self &); //purposely not implemented
00205   void operator=(const Self &);       //purposely not implemented
00206 };
00207 } // end namespace itk
00208 
00209 #ifndef ITK_MANUAL_INSTANTIATION
00210 #include "itkMirrorPadImageFilter.hxx"
00211 #endif
00212 
00213 #endif
00214