Medical Imaging Interaction Toolkit  2018.4.99-87d68d9f
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);
61 
62  itkCloneMacro(Self);
63 
64  itkGetConstMacro(BackgroundValue, float);
65  itkSetMacro(BackgroundValue, float);
66 
67  itkGetConstMacro(MarginFactor, float);
68  itkSetMacro(MarginFactor, float);
69 
70  itkGetMacro(CroppingRegion, RegionType);
71 
72  // Use this method to manually set a region
73  void SetCroppingRegion(RegionType overrideRegion);
74 
75  virtual const PixelType GetOutputPixelType();
76 
77  protected:
78  // default constructor
80 
81  // default destructor
82  ~AutoCropImageFilter() override;
83 
84  // This method calculates the actual smallest box
85  void ComputeNewImageBounds();
86 
87  // Crops the image using the itk::RegionOfInterestImageFilter and creates the new output image
88  template <typename TPixel, unsigned int VImageDimension>
89  void ITKCrop3DImage(itk::Image<TPixel, VImageDimension> *inputItkImage, unsigned int timestep);
90 
91  // Here, the output image is initialized by the input and the newly calculated region
92  void GenerateOutputInformation() override;
93 
94  // Purposely not implemented
95  void GenerateInputRequestedRegion() override;
96 
97  // Crops the image on all time steps
98  void GenerateData() override;
99 
101 
102  RegionType m_CroppingRegion;
103 
105 
106  typedef itk::Image<float, 3> ImageType;
107  typedef ImageType::Pointer ImagePointer;
108 
109  RegionType::SizeType m_RegionSize;
110  RegionType::IndexType m_RegionIndex;
111 
113 
116 
118  };
119 
120 } // namespace mitk
121 
122 #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