ITK  4.9.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 >
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;
75  typedef typename HistogramType::SizeType HistogramSizeType;
76  typedef typename HistogramType::MeasurementType HistogramMeasurementType;
77  typedef typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType;
78 
81 
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();
141 
142  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
143 
154 
155  // Where the histogram is actually computed
156  virtual void GenerateData() ITK_OVERRIDE;
157 
158 private:
159  SampleToHistogramFilter(const Self &) ITK_DELETE_FUNCTION;
160  void operator=(const Self &) ITK_DELETE_FUNCTION;
161 
164  {
166  {
167  MeasurementType fromMax = static_cast<MeasurementType>
169  MeasurementType fromMin = static_cast<MeasurementType>
172 
173  if (from >= fromMax)
174  {
176  }
177  else if (from <= fromMin)
178  {
180  }
181  }
182  return static_cast<HistogramMeasurementType>(from);
183  }
184 
185 }; // end of class
186 } // end of namespace Statistics
187 } // end of namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 #include "itkSampleToHistogramFilter.hxx"
191 #endif
192 
193 #endif
virtual const SampleType * GetInput() const
virtual void PrintSelf(std::ostream &os, Indent indent) const override
SimpleDataObjectDecorator< HistogramSizeType > InputHistogramSizeObjectType
Light weight base class for most itk classes.
SimpleDataObjectDecorator< HistogramMeasurementVectorType > InputHistogramMeasurementVectorObjectType
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
SimpleDataObjectDecorator< bool > InputBooleanObjectType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
DataObject::Pointer DataObjectPointer
SampleType::MeasurementVectorType MeasurementVectorType
static T min(const T &)
HistogramType::MeasurementType HistogramMeasurementType
MeasurementVectorType::ValueType MeasurementType
const HistogramType * GetOutput() const
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
static T max(const T &)
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
SimpleDataObjectDecorator< HistogramMeasurementType > InputHistogramMeasurementObjectType
Standard exception handling object.
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
virtual void GenerateData() override
Computes the Histogram corresponding to a Sample.
HistogramMeasurementType SafeAssign(MeasurementType from) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
virtual void GraftOutput(DataObject *output)
Base class for all data objects in ITK.
virtual void SetInput(const SampleType *sample)