ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkCropImageFilter.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 __itkCropImageFilter_h
00019 #define __itkCropImageFilter_h
00020 
00021 #include "itkExtractImageFilter.h"
00022 
00023 namespace itk
00024 {
00042 template< class TInputImage, class TOutputImage >
00043 class ITK_EXPORT CropImageFilter:
00044   public ExtractImageFilter< TInputImage, TOutputImage >
00045 {
00046 public:
00048   typedef CropImageFilter                                 Self;
00049   typedef ExtractImageFilter< TInputImage, TOutputImage > Superclass;
00050   typedef SmartPointer< Self >                            Pointer;
00051   typedef SmartPointer< const Self >                      ConstPointer;
00052 
00054   itkNewMacro(Self);
00055 
00057   itkTypeMacro(CropImageFilter, ExtractImageFilter);
00058 
00060   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00061   typedef typename Superclass::InputImageRegionType  InputImageRegionType;
00062 
00064   typedef typename Superclass::OutputImagePixelType OutputImagePixelType;
00065   typedef typename Superclass::InputImagePixelType  InputImagePixelType;
00066 
00068   typedef typename Superclass::OutputImageIndexType OutputImageIndexType;
00069   typedef typename Superclass::InputImageIndexType  InputImageIndexType;
00070   typedef typename Superclass::OutputImageSizeType  OutputImageSizeType;
00071   typedef typename Superclass::InputImageSizeType   InputImageSizeType;
00072   typedef InputImageSizeType                        SizeType;
00073 
00075   itkStaticConstMacro(InputImageDimension, unsigned int,
00076                       Superclass::InputImageDimension);
00077   itkStaticConstMacro(OutputImageDimension, unsigned int,
00078                       Superclass::OutputImageDimension);
00080 
00082   itkSetMacro(UpperBoundaryCropSize, SizeType);
00083   itkGetConstMacro(UpperBoundaryCropSize, SizeType);
00084   itkSetMacro(LowerBoundaryCropSize, SizeType);
00085   itkGetConstMacro(LowerBoundaryCropSize, SizeType);
00087 
00088   void SetBoundaryCropSize(const SizeType & s)
00089   {
00090     this->SetUpperBoundaryCropSize(s);
00091     this->SetLowerBoundaryCropSize(s);
00092   }
00093 
00094 #ifdef ITK_USE_CONCEPT_CHECKING
00095 
00096   itkConceptMacro( InputConvertibleToOutputCheck,
00097                    ( Concept::Convertible< InputImagePixelType, OutputImagePixelType > ) );
00098   itkConceptMacro( SameDimensionCheck,
00099                    ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00100 
00102 #endif
00103 protected:
00104   CropImageFilter()
00105   {
00106     this->SetDirectionCollapseToSubmatrix();
00107     m_UpperBoundaryCropSize.Fill(0);
00108     m_LowerBoundaryCropSize.Fill(0);
00109   }
00111 
00112   ~CropImageFilter() {}
00113   void PrintSelf(std::ostream & os, Indent indent) const;
00114 
00115   void GenerateOutputInformation();
00116 
00117 private:
00118   CropImageFilter(const Self &); //purposely not implemented
00119   void operator=(const Self &);  //purposely not implemented
00120 
00121   SizeType m_UpperBoundaryCropSize;
00122   SizeType m_LowerBoundaryCropSize;
00123 };
00124 } // end namespace itk
00125 
00126 #ifndef ITK_MANUAL_INSTANTIATION
00127 #include "itkCropImageFilter.hxx"
00128 #endif
00129 
00130 #endif
00131