Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkAutoCropImageFilter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __mitkAutoCropImageFilter_h_
18 #define __mitkAutoCropImageFilter_h_
19 
21 #include "mitkCommon.h"
22 #include "mitkImageTimeSelector.h"
23 #include "mitkSubImageSelector.h"
24 
25 #include <itkImage.h>
26 #include <itkImageRegion.h>
27 
28 namespace mitk
29 {
59  {
60  public:
61  typedef itk::ImageRegion<3> RegionType;
62 
64 
65  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
66 
67  itkGetConstMacro(BackgroundValue, float);
68  itkSetMacro(BackgroundValue, float);
69 
70  itkGetConstMacro(MarginFactor, float);
71  itkSetMacro(MarginFactor, float);
72 
73  itkGetMacro(CroppingRegion, RegionType);
74 
75  // Use this method to manually set a region
76  void SetCroppingRegion(RegionType overrideRegion);
77 
78  virtual const PixelType GetOutputPixelType();
79 
80  protected:
81  // default constructor
83 
84  // default destructor
85  virtual ~AutoCropImageFilter();
86 
87  // This method calculates the actual smallest box
88  void ComputeNewImageBounds();
89 
90  // Crops the image using the itk::RegionOfInterestImageFilter and creates the new output image
91  template <typename TPixel, unsigned int VImageDimension>
92  void ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage, unsigned int timestep);
93 
94  // Here, the output image is initialized by the input and the newly calculated region
95  virtual void GenerateOutputInformation() override;
96 
97  // Purposely not implemented
98  virtual void GenerateInputRequestedRegion() override;
99 
100  // Crops the image on all time steps
101  virtual void GenerateData() override;
102 
103  float m_BackgroundValue;
104 
105  RegionType m_CroppingRegion;
106 
107  float m_MarginFactor;
108 
109  typedef itk::Image<float, 3> ImageType;
110  typedef ImageType::Pointer ImagePointer;
111 
112  RegionType::SizeType m_RegionSize;
113  RegionType::IndexType m_RegionIndex;
114 
115  mitk::ImageTimeSelector::Pointer m_TimeSelector;
116 
117  mitk::SlicedData::RegionType m_InputRequestedRegion;
118  itk::TimeStamp m_TimeOfHeaderInitialization;
119 
120  bool m_OverrideCroppingRegion;
121  };
122 
123 } // namespace mitk
124 
125 #endif
Shrink the image borders to a minimum considering a background color.
Superclass of all classes generating some kind of mitk::BaseData.
DataCollection - Class to facilitate loading/accessing structured data.
itk::Image< float, 3 > ImageType
#define MITKALGORITHMSEXT_EXPORT
Super class of data objects consisting of slices.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
Image class for storing images.
Definition: mitkImage.h:76
Provides access to a volume at a specific time of the input image.
Base class of all classes providing access to parts of an image.
Class for defining the data type of pixels.
Definition: mitkPixelType.h:55
itk::ImageRegion< 3 > RegionType