Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef __mitkAutoCropImageFilter_h_
14 #define __mitkAutoCropImageFilter_h_
15 
17 #include "mitkCommon.h"
18 #include "mitkImageTimeSelector.h"
19 #include "mitkSubImageSelector.h"
20 
21 #include <itkImage.h>
22 #include <itkImageRegion.h>
23 
24 namespace mitk
25 {
54  {
55  public:
56  typedef itk::ImageRegion<3> RegionType;
57 
59 
60  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
61 
62  itkGetConstMacro(BackgroundValue, float);
63  itkSetMacro(BackgroundValue, float);
64 
65  itkGetConstMacro(MarginFactor, float);
66  itkSetMacro(MarginFactor, float);
67 
68  itkGetMacro(CroppingRegion, RegionType);
69 
70  // Use this method to manually set a region
71  void SetCroppingRegion(RegionType overrideRegion);
72 
73  virtual const PixelType GetOutputPixelType();
74 
75  protected:
76  // default constructor
78 
79  // default destructor
80  ~AutoCropImageFilter() override;
81 
82  // This method calculates the actual smallest box
83  void ComputeNewImageBounds();
84 
85  // Crops the image using the itk::RegionOfInterestImageFilter and creates the new output image
86  template <typename TPixel, unsigned int VImageDimension>
87  void ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage, unsigned int timestep);
88 
89  // Here, the output image is initialized by the input and the newly calculated region
90  void GenerateOutputInformation() override;
91 
92  // Purposely not implemented
93  void GenerateInputRequestedRegion() override;
94 
95  // Crops the image on all time steps
96  void GenerateData() override;
97 
99 
100  RegionType m_CroppingRegion;
101 
103 
104  typedef itk::Image<float, 3> ImageType;
105  typedef ImageType::Pointer ImagePointer;
106 
107  RegionType::SizeType m_RegionSize;
108  RegionType::IndexType m_RegionIndex;
109 
111 
114 
116  };
117 
118 } // namespace mitk
119 
120 #endif
mitk::SlicedData::RegionType m_InputRequestedRegion
Shrink the image borders to a minimum considering a background color.
RegionType::IndexType m_RegionIndex
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
itk::ImageRegion< RegionDimension > RegionType
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
Base class of all classes providing access to parts of an image.
mitk::ImageTimeSelector::Pointer m_TimeSelector
Class for defining the data type of pixels.
Definition: mitkPixelType.h:51
itk::ImageRegion< 3 > RegionType