ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkSampleToHistogramFilter.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 itkSampleToHistogramFilter_h
19 #define itkSampleToHistogramFilter_h
20 
21 #include "itkMacro.h"
22 #include "itkProcessObject.h"
25 
26 itkDeclareExceptionMacro( SampleToHistogramFilterException, ExceptionObject, "Histogram-related Exception");
27 itkDeclareExceptionMacro( MissingHistogramSizeInput, SampleToHistogramFilterException, "Histogram Size input is missing");
28 itkDeclareExceptionMacro( MissingHistogramMarginalScaleInput, SampleToHistogramFilterException, "Histogram marginal scale input is missing");
29 itkDeclareExceptionMacro( NullSizeHistogramInputMeasurementVectorSize, SampleToHistogramFilterException, "Input sample MeasurementVectorSize is zero");
30 itkDeclareExceptionMacro( MissingHistogramBinMaximumInput, SampleToHistogramFilterException, "Histogram Bin Maximum input is missing");
31 itkDeclareExceptionMacro( MissingHistogramBinMinimumInput, SampleToHistogramFilterException, "Histogram Bin Minimum input is missing");
32 itkDeclareExceptionMacro( HistogramWrongNumberOfComponents, SampleToHistogramFilterException, "Histogram has wrong number of components");
33 
34 namespace itk
35 {
36 namespace Statistics
37 {
38 
54 template< typename TSample, typename THistogram >
55 class ITK_TEMPLATE_EXPORT SampleToHistogramFilter:public ProcessObject
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_ASSIGN(SampleToHistogramFilter);
59 
65 
68 
70  itkNewMacro(Self);
71 
73  using SampleType = TSample;
74  using HistogramType = THistogram;
75  using MeasurementVectorType = typename SampleType::MeasurementVectorType;
76  using MeasurementType = typename MeasurementVectorType::ValueType;
78  using HistogramMeasurementType = typename HistogramType::MeasurementType;
79  using HistogramMeasurementVectorType = typename HistogramType::MeasurementVectorType;
80 
82  using DataObjectPointer = typename Superclass::DataObjectPointer;
83 
84  using Superclass::SetInput;
85 
87  virtual void SetInput(const SampleType *sample);
88 
89  virtual const SampleType * GetInput() const;
90 
92  const HistogramType * GetOutput() const;
93 
96 
99 
103 
106 
113  itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
114 
118  itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
119 
123  itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
124  itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
126 
131  itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
132 
135  virtual void GraftOutput(DataObject *output);
136 
137 protected:
139  ~SampleToHistogramFilter() override = default;
140 
141  void PrintSelf(std::ostream & os, Indent indent) const override;
142 
150  using Superclass::MakeOutput;
151  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override;
153 
154  // Where the histogram is actually computed
155  void GenerateData() override;
156 
157 private:
160  {
162  {
163  auto fromMax = static_cast<MeasurementType>
165  auto fromMin = static_cast<MeasurementType>
168 
169  if (from >= fromMax)
170  {
172  }
173  else if (from <= fromMin)
174  {
176  }
177  }
178  return static_cast<HistogramMeasurementType>(from);
179  }
180 
181 }; // end of class
182 } // end of namespace Statistics
183 } // end of namespace itk
184 
185 #ifndef ITK_MANUAL_INSTANTIATION
186 #include "itkSampleToHistogramFilter.hxx"
187 #endif
188 
189 #endif
typename MeasurementVectorType::ValueType MeasurementType
Light weight base class for most itk classes.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Define numeric traits for std::vector.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
typename HistogramType::SizeType HistogramSizeType
class ITK_FORWARD_EXPORT ProcessObject
Definition: itkDataObject.h:40
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
Standard exception handling object.
typename SampleType::MeasurementVectorType MeasurementVectorType
Computes the Histogram corresponding to a Sample.
HistogramMeasurementType SafeAssign(MeasurementType from) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename HistogramType::MeasurementType HistogramMeasurementType
Base class for all data objects in ITK.