ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelImageToStatisticsLabelMapFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkLabelImageToStatisticsLabelMapFilter_h
19 #define itkLabelImageToStatisticsLabelMapFilter_h
20 
24 
25 namespace itk
26 {
40 template< typename TInputImage, typename TFeatureImage, typename TOutputImage =
41  LabelMap< StatisticsLabelObject< typename TInputImage::PixelType,
42  TInputImage::ImageDimension > > >
43 class ITK_TEMPLATE_EXPORT LabelImageToStatisticsLabelMapFilter:
44  public ImageToImageFilter< TInputImage, TOutputImage >
45 {
46 public:
47  ITK_DISALLOW_COPY_AND_ASSIGN(LabelImageToStatisticsLabelMapFilter);
48 
54 
56  using InputImageType = TInputImage;
57  using InputImagePointer = typename InputImageType::Pointer;
58  using InputImageConstPointer = typename InputImageType::ConstPointer;
60  using InputImagePixelType = typename InputImageType::PixelType;
61 
62  using OutputImageType = TOutputImage;
63  using OutputImagePointer = typename OutputImageType::Pointer;
64  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
66  using OutputImagePixelType = typename OutputImageType::PixelType;
67  using LabelObjectType = typename OutputImageType::LabelObjectType;
68 
69  using FeatureImageType = TFeatureImage;
70  using FeatureImagePointer = typename FeatureImageType::Pointer;
71  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
72  using FeatureImagePixelType = typename FeatureImageType::PixelType;
73 
75  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
76  static constexpr unsigned int OutputImageDimension = TInputImage::ImageDimension;
77  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
78 
81 
83  itkNewMacro(Self);
84 
88 
89 #ifdef ITK_USE_CONCEPT_CHECKING
90  // Begin concept checking
91  itkConceptMacro( InputEqualityComparableCheck,
93  itkConceptMacro( IntConvertibleToInputCheck,
95  itkConceptMacro( InputOStreamWritableCheck,
97  // End concept checking
98 #endif
99 
104  itkSetMacro(BackgroundValue, OutputImagePixelType);
105  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
107 
112  itkSetMacro(ComputeFeretDiameter, bool);
113  itkGetConstReferenceMacro(ComputeFeretDiameter, bool);
114  itkBooleanMacro(ComputeFeretDiameter);
116 
121  itkSetMacro(ComputePerimeter, bool);
122  itkGetConstReferenceMacro(ComputePerimeter, bool);
123  itkBooleanMacro(ComputePerimeter);
125 
127  void SetFeatureImage(const TFeatureImage *input)
128  {
129  // Process object is not const-correct so the const casting is required.
130  this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) );
131  }
132 
135  {
136  return static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) );
137  }
138 
140  void SetInput1(const InputImageType *input)
141  {
142  this->SetInput(input);
143  }
144 
146  void SetInput2(const FeatureImageType *input)
147  {
148  this->SetFeatureImage(input);
149  }
150 
157  itkSetMacro(ComputeHistogram, bool);
158  itkGetConstReferenceMacro(ComputeHistogram, bool);
159  itkBooleanMacro(ComputeHistogram);
161 
167  itkSetMacro(NumberOfBins, unsigned int);
168  itkGetConstReferenceMacro(NumberOfBins, unsigned int);
170 
171 protected:
173  ~LabelImageToStatisticsLabelMapFilter() override = default;
174  void PrintSelf(std::ostream & os, Indent indent) const override;
175 
179  void GenerateInputRequestedRegion() override;
180 
182  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) override;
183 
186  void GenerateData() override;
187 
188 private:
192  unsigned int m_NumberOfBins;
194 }; // end of class
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 #include "itkLabelImageToStatisticsLabelMapFilter.hxx"
199 #endif
200 
201 #endif
typename FeatureImageType::ConstPointer FeatureImageConstPointer
convert a labeled image to a label collection image
typename OutputImageType::Pointer OutputImagePointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename OutputImageType::LabelObjectType LabelObjectType
a convenient class to convert a label image to a label map and valuate the statistics attributes at o...
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
typename InputImageType::RegionType InputImageRegionType
typename OutputImageType::ConstPointer OutputImageConstPointer
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
The valuator class for the StatisticsLabelObject.
#define itkConceptMacro(name, concept)
typename InputImageType::ConstPointer InputImageConstPointer
Base class for all data objects in ITK.