ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkSampleToHistogramFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
26itkDeclareExceptionMacro(SampleToHistogramFilterException, ExceptionObject, "Histogram-related Exception");
27itkDeclareExceptionMacro(MissingHistogramSizeInput,
29 "Histogram Size input is missing");
30itkDeclareExceptionMacro(MissingHistogramMarginalScaleInput,
32 "Histogram marginal scale input is missing");
33itkDeclareExceptionMacro(NullSizeHistogramInputMeasurementVectorSize,
35 "Input sample MeasurementVectorSize is zero");
36itkDeclareExceptionMacro(MissingHistogramBinMaximumInput,
38 "Histogram Bin Maximum input is missing");
39itkDeclareExceptionMacro(MissingHistogramBinMinimumInput,
41 "Histogram Bin Minimum input is missing");
42itkDeclareExceptionMacro(HistogramWrongNumberOfComponents,
44 "Histogram has wrong number of components");
45
46namespace itk
47{
48namespace Statistics
49{
50
66
67template <typename TSample, typename THistogram>
68class ITK_TEMPLATE_EXPORT SampleToHistogramFilter : public ProcessObject
69{
70public:
71 ITK_DISALLOW_COPY_AND_MOVE(SampleToHistogramFilter);
72
78
80 itkOverrideGetNameOfClassMacro(SampleToHistogramFilter);
81
83 itkNewMacro(Self);
84
86 using SampleType = TSample;
87 using HistogramType = THistogram;
88 using MeasurementVectorType = typename SampleType::MeasurementVectorType;
89 using MeasurementType = typename MeasurementVectorType::ValueType;
90 using HistogramSizeType = typename HistogramType::SizeType;
91 using HistogramMeasurementType = typename HistogramType::MeasurementType;
92 using HistogramMeasurementVectorType = typename HistogramType::MeasurementVectorType;
93
95 using typename Superclass::DataObjectPointer;
96
98
100 virtual void
101 SetInput(const SampleType * sample);
102
103 virtual const SampleType *
104 GetInput() const;
105
107 const HistogramType *
108 GetOutput() const;
109
112
115
119
122
129 itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
130
134 itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
135
139 itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
140 itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
142
147 itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
148
151 virtual void
153
154protected:
156 ~SampleToHistogramFilter() override = default;
157
158 void
159 PrintSelf(std::ostream & os, Indent indent) const override;
160
172
173 // Where the histogram is actually computed
174 void
175 GenerateData() override;
176
177private:
181 {
183 {
187
188 if (from >= fromMax)
189 {
191 }
192 if (from <= fromMin)
193 {
195 }
196 }
197 return static_cast<HistogramMeasurementType>(from);
198 }
199
200}; // end of class
201} // end of namespace Statistics
202} // end of namespace itk
203
204#ifndef ITK_MANUAL_INSTANTIATION
205# include "itkSampleToHistogramFilter.hxx"
206#endif
207
208#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
Define additional traits for native types such as int or float.
static constexpr T max(const T &)
static constexpr T min(const T &)
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
DataObject::Pointer DataObjectPointer
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
SampleToHistogramFilterException(const char *file, unsigned int lineNumber)
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
Implements transparent reference counting.
SimpleDataObjectDecorator< bool > InputBooleanObjectType
virtual const SampleType * GetInput() const
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
HistogramMeasurementType SafeAssign(MeasurementType from) const
SimpleDataObjectDecorator< HistogramSizeType > InputHistogramSizeObjectType
typename SampleType::MeasurementVectorType MeasurementVectorType
typename HistogramType::MeasurementType HistogramMeasurementType
const HistogramType * GetOutput() const
void PrintSelf(std::ostream &os, Indent indent) const override
SimpleDataObjectDecorator< HistogramMeasurementType > InputHistogramMeasurementObjectType
SimpleDataObjectDecorator< HistogramMeasurementVectorType > InputHistogramMeasurementVectorObjectType
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
typename HistogramType::SizeType HistogramSizeType
ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
typename MeasurementVectorType::ValueType MeasurementType
virtual void SetInput(const SampleType *sample)
virtual void GraftOutput(DataObject *graft)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....