]> Creatis software - clitk.git/blob - itk/clitkCropLikeImageFilter.h
Merge branch 'master' of /home/dsarrut/clitk3.server
[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://www.centreleonberard.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     // I dont want to verify inputs information
69     virtual void VerifyInputInformation() { }
70
71   protected:
72     CropLikeImageFilter();
73     virtual ~CropLikeImageFilter() {}
74     
75     virtual void GenerateOutputInformation();
76     virtual void GenerateData();
77     virtual void GenerateInputRequestedRegion();
78     
79     PixelType m_BackgroundValue;
80     RegionType m_OutputRegion;
81     RegionType m_Region;
82     std::string m_LikeFilename;
83     bool m_LikeFilenameIsGiven;
84     PointType m_Origin;
85     const itk::ImageBase<ImageDimension> * m_LikeImage;
86     std::vector<bool> m_CropAlongThisDimension;
87     
88     PointType m_StartPoint;         // start point in physical world
89     IndexType m_StartSourceIndex;   // start index in "source" image 
90     IndexType m_StartDestIndex;     // start index in "destination" image 
91     
92     PointType m_StopPoint;         // stop point in physical world
93     IndexType m_StopSourceIndex;   // stop index in "source" image 
94     IndexType m_StopDestIndex;     // stop index in "destination" image 
95     
96   private:
97     CropLikeImageFilter(const Self&); //purposely not implemented
98     void operator=(const Self&); //purposely not implemented
99     
100   }; // end class
101   //--------------------------------------------------------------------
102
103 } // end namespace clitk
104 //--------------------------------------------------------------------
105
106 #ifndef ITK_MANUAL_INSTANTIATION
107 #include "clitkCropLikeImageFilter.txx"
108 #endif
109
110 #endif // # CROPLIKEIMAGEFILTER