1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKCROPLIKEIMAGEFILTER_H
20 #define CLITKCROPLIKEIMAGEFILTER_H
22 #include <itkImageToImageFilter.h>
26 //--------------------------------------------------------------------
28 Perform various cropping operation on a image
30 //--------------------------------------------------------------------
32 template <class ImageType>
33 class ITK_EXPORT CropLikeImageFilter: public itk::ImageToImageFilter<ImageType, ImageType> {
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;
41 /** Method for creation through the object factory. */
44 /** Run-time type information (and related methods). */
45 itkTypeMacro(CropLikeImageFilter, ImageToImageFilter);
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;
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);
61 // Set Background if 'like' is greater than input
62 itkSetMacro(BackgroundValue, PixelType);
63 itkGetConstMacro(BackgroundValue, PixelType);
65 /** ImageDimension constants */
66 itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
69 CropLikeImageFilter();
70 virtual ~CropLikeImageFilter() {}
72 virtual void GenerateOutputInformation();
73 virtual void GenerateData();
74 virtual void GenerateInputRequestedRegion();
76 PixelType m_BackgroundValue;
77 RegionType m_OutputRegion;
79 std::string m_LikeFilename;
80 bool m_LikeFilenameIsGiven;
82 const itk::ImageBase<ImageDimension> * m_LikeImage;
83 std::vector<bool> m_CropAlongThisDimension;
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
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
94 CropLikeImageFilter(const Self&); //purposely not implemented
95 void operator=(const Self&); //purposely not implemented
98 //--------------------------------------------------------------------
100 } // end namespace clitk
101 //--------------------------------------------------------------------
103 #ifndef ITK_MANUAL_INSTANTIATION
104 #include "clitkCropLikeImageFilter.txx"
107 #endif // # CROPLIKEIMAGEFILTER