ITK  4.3.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< class TSample, class THistogram >
55 class ITK_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;
75  typedef typename HistogramType::SizeType HistogramSizeType;
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 
123  itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
124  itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
126 
130  itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
131 
134  virtual void GraftOutput(DataObject *output);
135 
136 protected:
138  virtual ~SampleToHistogramFilter();
139 
140  void PrintSelf(std::ostream & os, Indent indent) const;
141 
149  using Superclass::MakeOutput;
150  virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx);
152 
153  // Where the histogram is actually computed
154  virtual void GenerateData();
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
192