ITK  4.6.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 
115 
120 
126 
130  itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
131 
134  virtual void GraftOutput(DataObject *output);
135 
136 protected:
138  virtual ~SampleToHistogramFilter();
139 
140  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
141 
152 
153  // Where the histogram is actually computed
154  virtual void GenerateData() ITK_OVERRIDE;
155 
156 private:
157  SampleToHistogramFilter(const Self &); //purposely not implemented
158  void operator=(const Self &); //purposely not implemented
159 
162  {
164  {
165  MeasurementType fromMax = static_cast<MeasurementType>
167  MeasurementType fromMin = static_cast<MeasurementType>
170 
171  if (from >= fromMax)
172  {
174  }
175  else if (from <= fromMin)
176  {
178  }
179  }
180  return static_cast<HistogramMeasurementType>(from);
181  }
182 
183 }; // end of class
184 } // end of namespace Statistics
185 } // end of namespace itk
186 
187 #ifndef ITK_MANUAL_INSTANTIATION
188 #include "itkSampleToHistogramFilter.hxx"
189 #endif
190 
191 #endif
virtual const SampleType * GetInput() const
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...
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)
SimpleDataObjectDecorator< HistogramMeasurementType > InputHistogramMeasurementObjectType
Standard exception handling object.
itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
Computes the Histogram corresponding to a Sample.
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
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)
virtual void GenerateData() ITK_OVERRIDE
Base class for all data objects in ITK.
virtual void SetInput(const SampleType *sample)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE