]> Creatis software - clitk.git/blob - itk/clitkAutoCropFilter.h
Set Directions to CropImage Like
[clitk.git] / itk / clitkAutoCropFilter.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 CLITKAUTOCROPFILTER_H
20 #define CLITKAUTOCROPFILTER_H
21
22 #include <itkImageToImageFilter.h>
23
24 namespace clitk {
25   
26   //--------------------------------------------------------------------
27   /*
28     Perform auto crop on a Label Image (with Background defined)
29   */
30   //--------------------------------------------------------------------
31   
32   template <class ImageType>
33   class ITK_EXPORT AutoCropFilter: 
34     public itk::ImageToImageFilter<ImageType, ImageType> {
35
36   public:
37     /** Standard class typedefs. */
38     typedef AutoCropFilter                                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(AutoCropFilter, ImageToImageFilter);
48
49     /** Some convenient typedefs. */
50     typedef typename ImageType::ConstPointer ImageConstPointer;
51     typedef typename ImageType::Pointer      ImagePointer;
52     typedef typename ImageType::PixelType    ImagePixelType;
53     typedef typename ImageType::RegionType   ImageRegionType;
54     typedef long LabelType;
55
56     /** Connect one of the operands for pixel-wise addition */
57     void SetInput( const ImageType * image) ITK_OVERRIDE;
58     
59     // LabelImage information (BG)
60     void SetBackgroundValue(ImagePixelType p);
61     
62     // Use a border
63     itkSetMacro(UseBorder, bool);
64     itkGetConstMacro(UseBorder, bool);
65     itkBooleanMacro(UseBorder);
66
67     /** ImageDimension constants */
68     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
69     
70   protected:
71     AutoCropFilter();
72     virtual ~AutoCropFilter() {}
73     
74     virtual void GenerateOutputInformation() ITK_OVERRIDE;
75     virtual void GenerateData() ITK_OVERRIDE;
76     
77     ImagePixelType m_BackgroundValue;
78     ImageRegionType m_Region;
79     ImagePointer m_labeImage;
80     bool m_UseBorder;
81     
82   private:
83     AutoCropFilter(const Self&); //purposely not implemented
84     void operator=(const Self&); //purposely not implemented
85     
86   }; // end class
87   //--------------------------------------------------------------------
88
89 } // end namespace clitk
90 //--------------------------------------------------------------------
91
92 #ifndef ITK_MANUAL_INSTANTIATION
93 #include "clitkAutoCropFilter.txx"
94 #endif
95
96 #endif