]> Creatis software - clitk.git/blob - itk/clitkCropLikeImageFilter.h
new CropImage with AutoCrop and CropLike
[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: 
34     public itk::ImageToImageFilter<ImageType, ImageType> {
35
36   public:
37     /** Standard class typedefs. */
38     typedef CropLikeImageFilter                            Self;
39     typedef itk::ImageToImageFilter<ImageType, ImageType>  Superclass;
40     typedef itk::SmartPointer<Self>                        Pointer;
41     typedef itk::SmartPointer<const Self>                  ConstPointer;
42     
43     /** Method for creation through the object factory. */
44     itkNewMacro(Self);
45     
46     /** Run-time type information (and related methods). */
47     itkTypeMacro(CropLikeImageFilter, ImageToImageFilter);
48
49     /** Some convenient typedefs. */
50     typedef typename ImageType::ConstPointer ImageConstPointer;
51     typedef typename ImageType::Pointer      ImagePointer;
52     typedef typename ImageType::PixelType    PixelType;
53     typedef typename ImageType::RegionType   RegionType;
54     typedef typename ImageType::PointType    PointType;
55
56     /** Input image to crop */
57     void SetInput(const ImageType * image);
58     
59     /** Image filename for Crop Like */
60     void SetCropLikeFilename(std::string f);
61     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like);
62     void SetCropLikeImage(const itk::ImageBase<ImageType::ImageDimension> * like, int axe);
63
64     /** ImageDimension constants */
65     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
66     
67   protected:
68     CropLikeImageFilter();
69     virtual ~CropLikeImageFilter() {}
70     
71     virtual void GenerateOutputInformation();
72     virtual void GenerateData();
73     
74     RegionType m_Region;
75     std::string m_LikeFilename;
76     bool m_LikeFilenameIsGiven;
77     PointType m_Origin;
78     const itk::ImageBase<ImageDimension> * m_LikeImage;
79     std::vector<bool> m_CropAlongThisDimension;
80     
81   private:
82     CropLikeImageFilter(const Self&); //purposely not implemented
83     void operator=(const Self&); //purposely not implemented
84     
85   }; // end class
86   //--------------------------------------------------------------------
87
88 } // end namespace clitk
89 //--------------------------------------------------------------------
90
91 #ifndef ITK_MANUAL_INSTANTIATION
92 #include "clitkCropLikeImageFilter.txx"
93 #endif
94
95 #endif // # CROPLIKEIMAGEFILTER