]> Creatis software - clitk.git/blob - itk/clitkCropLikeImageFilter.h
221f61cd3fc7934738d7b9980352f4c6c9d06899
[clitk.git] / itk / clitkCropLikeImageFilter.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18
19 #ifndef CLITKCROPLIKEIMAGEFILTER_H
20 #define CLITKCROPLIKEIMAGEFILTER_H
21
22 #include <itkImageToImageFilter.h>
23
24 namespace clitk {
25   
26   //--------------------------------------------------------------------
27   /*
28     Perform various cropping operation on a image
29   */
30   //--------------------------------------------------------------------
31   
32   template <class ImageType>
33   class ITK_EXPORT CropLikeImageFilter: public itk::ImageToImageFilter<ImageType, ImageType> {
34   public:
35     /** Standard class typedefs. */
36     typedef CropLikeImageFilter                            Self;
37     typedef itk::ImageToImageFilter<ImageType, ImageType>  Superclass;
38     typedef itk::SmartPointer<Self>                        Pointer;
39     typedef itk::SmartPointer<const Self>                  ConstPointer;
40     
41     /** Method for creation through the object factory. */
42     itkNewMacro(Self);
43     
44     /** Run-time type information (and related methods). */
45     itkTypeMacro(CropLikeImageFilter, ImageToImageFilter);
46
47     /** Some convenient typedefs. */
48     typedef typename ImageType::ConstPointer ImageConstPointer;
49     typedef typename ImageType::Pointer      ImagePointer;
50     typedef typename ImageType::PixelType    PixelType;
51     typedef typename ImageType::RegionType   RegionType;
52     typedef typename ImageType::PointType    PointType;
53     typedef typename ImageType::IndexType    IndexType;
54     typedef typename ImageType::SizeType     SizeType;
55
56     /** Image filename for Crop Like */
57     void SetCropLikeFilename(std::string f);
58     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like);
59     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like, int axe);
60
61     // Set Background if 'like' is greater than input
62     itkSetMacro(BackgroundValue, PixelType);
63     itkGetConstMacro(BackgroundValue, PixelType); 
64
65     /** ImageDimension constants */
66     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
67
68   protected:
69     CropLikeImageFilter();
70     virtual ~CropLikeImageFilter() {}
71     
72     virtual void GenerateOutputInformation();
73     virtual void GenerateData();
74     virtual void GenerateInputRequestedRegion();
75     
76     PixelType m_BackgroundValue;
77     RegionType m_OutputRegion;
78     RegionType m_Region;
79     std::string m_LikeFilename;
80     bool m_LikeFilenameIsGiven;
81     PointType m_Origin;
82     const itk::ImageBase<ImageDimension> * m_LikeImage;
83     std::vector<bool> m_CropAlongThisDimension;
84     
85     PointType m_StartPoint;         // start point in physical world
86     IndexType m_StartSourceIndex;   // start index in "source" image 
87     IndexType m_StartDestIndex;     // start index in "destination" image 
88     
89     PointType m_StopPoint;         // stop point in physical world
90     IndexType m_StopSourceIndex;   // stop index in "source" image 
91     IndexType m_StopDestIndex;     // stop index in "destination" image 
92     
93   private:
94     CropLikeImageFilter(const Self&); //purposely not implemented
95     void operator=(const Self&); //purposely not implemented
96     
97   }; // end class
98   //--------------------------------------------------------------------
99
100 } // end namespace clitk
101 //--------------------------------------------------------------------
102
103 #ifndef ITK_MANUAL_INSTANTIATION
104 #include "clitkCropLikeImageFilter.txx"
105 #endif
106
107 #endif // # CROPLIKEIMAGEFILTER