18 #ifndef itkSampleToHistogramFilter_h
19 #define itkSampleToHistogramFilter_h
26 itkDeclareExceptionMacro(SampleToHistogramFilterException, ExceptionObject,
"Histogram-related Exception");
27 itkDeclareExceptionMacro(MissingHistogramSizeInput,
28 SampleToHistogramFilterException,
29 "Histogram Size input is missing");
30 itkDeclareExceptionMacro(MissingHistogramMarginalScaleInput,
31 SampleToHistogramFilterException,
32 "Histogram marginal scale input is missing");
33 itkDeclareExceptionMacro(NullSizeHistogramInputMeasurementVectorSize,
34 SampleToHistogramFilterException,
35 "Input sample MeasurementVectorSize is zero");
36 itkDeclareExceptionMacro(MissingHistogramBinMaximumInput,
37 SampleToHistogramFilterException,
38 "Histogram Bin Maximum input is missing");
39 itkDeclareExceptionMacro(MissingHistogramBinMinimumInput,
40 SampleToHistogramFilterException,
41 "Histogram Bin Minimum input is missing");
42 itkDeclareExceptionMacro(HistogramWrongNumberOfComponents,
43 SampleToHistogramFilterException,
44 "Histogram has wrong number of components");
67 template <
typename TSample,
typename THistogram>
68 class ITK_TEMPLATE_EXPORT SampleToHistogramFilter :
public ProcessObject
71 ITK_DISALLOW_COPY_AND_MOVE(SampleToHistogramFilter);
74 using Self = SampleToHistogramFilter;
76 using Pointer = SmartPointer<Self>;
80 itkOverrideGetNameOfClassMacro(SampleToHistogramFilter);
86 using SampleType = TSample;
87 using HistogramType = THistogram;
88 using MeasurementVectorType =
typename SampleType::MeasurementVectorType;
89 using MeasurementType =
typename MeasurementVectorType::ValueType;
91 using HistogramMeasurementType =
typename HistogramType::MeasurementType;
92 using HistogramMeasurementVectorType =
typename HistogramType::MeasurementVectorType;
95 using typename Superclass::DataObjectPointer;
97 using Superclass::SetInput;
101 SetInput(
const SampleType * sample);
103 virtual const SampleType *
107 const HistogramType *
111 using InputHistogramSizeObjectType = SimpleDataObjectDecorator<HistogramSizeType>;
114 using InputHistogramMeasurementObjectType = SimpleDataObjectDecorator<HistogramMeasurementType>;
118 using InputHistogramMeasurementVectorObjectType = SimpleDataObjectDecorator<HistogramMeasurementVectorType>;
121 using InputBooleanObjectType = SimpleDataObjectDecorator<bool>;
129 itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
134 itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
139 itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
140 itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
147 itkSetGetDecoratedInputMacro(AutoMinimumMaximum,
bool);
155 SampleToHistogramFilter();
156 ~SampleToHistogramFilter()
override =
default;
159 PrintSelf(std::ostream & os, Indent indent)
const override;
168 using Superclass::MakeOutput;
170 MakeOutput(DataObjectPointerArraySizeType idx)
override;
175 GenerateData()
override;
179 HistogramMeasurementType
180 SafeAssign(MeasurementType from)
const
182 if (NumericTraits<HistogramMeasurementType>::is_integer)
192 else if (from <= fromMin)
197 return static_cast<HistogramMeasurementType>(from);
204 #ifndef ITK_MANUAL_INSTANTIATION
205 # include "itkSampleToHistogramFilter.hxx"