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::Statistics
47{
48
64
65template <typename TSample, typename THistogram>
66class ITK_TEMPLATE_EXPORT SampleToHistogramFilter : public ProcessObject
67{
68public:
69 ITK_DISALLOW_COPY_AND_MOVE(SampleToHistogramFilter);
70
76
78 itkOverrideGetNameOfClassMacro(SampleToHistogramFilter);
79
81 itkNewMacro(Self);
82
84 using SampleType = TSample;
85 using HistogramType = THistogram;
86 using MeasurementVectorType = typename SampleType::MeasurementVectorType;
87 using MeasurementType = typename MeasurementVectorType::ValueType;
88 using HistogramSizeType = typename HistogramType::SizeType;
89 using HistogramMeasurementType = typename HistogramType::MeasurementType;
90 using HistogramMeasurementVectorType = typename HistogramType::MeasurementVectorType;
91
93 using typename Superclass::DataObjectPointer;
94
96
98 virtual void
99 SetInput(const SampleType * sample);
100
101 virtual const SampleType *
102 GetInput() const;
103
105 const HistogramType *
106 GetOutput() const;
107
110
113
117
120
127 itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
128
132 itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
133
138 itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
139 itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
145 itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
146
149 virtual void
151
152protected:
154 ~SampleToHistogramFilter() override = default;
155
156 void
157 PrintSelf(std::ostream & os, Indent indent) const override;
158
171 // Where the histogram is actually computed
172 void
173 GenerateData() override;
174
175private:
179 {
181 {
184
185 if (from >= fromMax)
186 {
188 }
189 if (from <= fromMin)
190 {
192 }
193 }
194 return static_cast<HistogramMeasurementType>(from);
195 }
196
197}; // end of class
198} // namespace itk::Statistics
199
200#ifndef ITK_MANUAL_INSTANTIATION
201# include "itkSampleToHistogramFilter.hxx"
202#endif
203
204#endif
ExceptionObject() noexcept=default
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)