ITK  4.13.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:
63 
66 
68  itkNewMacro(Self);
69 
71  typedef TSample SampleType;
72  typedef THistogram HistogramType;
73  typedef typename SampleType::MeasurementVectorType MeasurementVectorType;
74  typedef typename MeasurementVectorType::ValueType MeasurementType;
76  typedef typename HistogramType::MeasurementType HistogramMeasurementType;
77  typedef typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType;
78 
80  typedef typename Superclass::DataObjectPointer DataObjectPointer;
81 
82  using Superclass::SetInput;
83 
85  virtual void SetInput(const SampleType *sample);
86 
87  virtual const SampleType * GetInput() const;
88 
90  const HistogramType * GetOutput() const;
91 
95 
99 
104 
107 
114  itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
115 
119  itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
120 
124  itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
125  itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
127 
132  itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
133 
136  virtual void GraftOutput(DataObject *output);
137 
138 protected:
140  virtual ~SampleToHistogramFilter() ITK_OVERRIDE;
141 
142  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
143 
151  using Superclass::MakeOutput;
152  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
154 
155  // Where the histogram is actually computed
156  virtual void GenerateData() ITK_OVERRIDE;
157 
158 private:
159  ITK_DISALLOW_COPY_AND_ASSIGN(SampleToHistogramFilter);
160 
163  {
165  {
166  MeasurementType fromMax = static_cast<MeasurementType>
168  MeasurementType fromMin = static_cast<MeasurementType>
171 
172  if (from >= fromMax)
173  {
175  }
176  else if (from <= fromMin)
177  {
179  }
180  }
181  return static_cast<HistogramMeasurementType>(from);
182  }
183 
184 }; // end of class
185 } // end of namespace Statistics
186 } // end of namespace itk
187 
188 #ifndef ITK_MANUAL_INSTANTIATION
189 #include "itkSampleToHistogramFilter.hxx"
190 #endif
191 
192 #endif
SimpleDataObjectDecorator< HistogramSizeType > InputHistogramSizeObjectType
Light weight base class for most itk classes.
SimpleDataObjectDecorator< HistogramMeasurementVectorType > InputHistogramMeasurementVectorObjectType
SimpleDataObjectDecorator< bool > InputBooleanObjectType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
SampleType::MeasurementVectorType MeasurementVectorType
HistogramType::MeasurementType HistogramMeasurementType
MeasurementVectorType::ValueType MeasurementType
static ITK_CONSTEXPR_FUNC T max(const T &)
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
SimpleDataObjectDecorator< HistogramMeasurementType > InputHistogramMeasurementObjectType
Standard exception handling object.
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
static ITK_CONSTEXPR_FUNC T min(const T &)
Computes the Histogram corresponding to a Sample.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
Base class for all data objects in ITK.