ITK  6.0.0
Insight Toolkit
itkImageToHistogramFilter.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 itkImageToHistogramFilter_h
19#define itkImageToHistogramFilter_h
20
21#include <mutex>
22
23#include "itkHistogram.h"
24#include "itkImageSink.h"
26#include "itkProgressReporter.h"
27
28namespace itk
29{
30namespace Statistics
31{
49template <typename TImage>
50class ITK_TEMPLATE_EXPORT ImageToHistogramFilter : public ImageSink<TImage>
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(ImageToHistogramFilter);
54
60
62 itkOverrideGetNameOfClassMacro(ImageToHistogramFilter);
63
65 itkNewMacro(Self);
66
67 using ImageType = TImage;
68 using PixelType = typename ImageType::PixelType;
72
79
80public:
82 const HistogramType *
83 GetOutput() const;
90
93
97
100
107 itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
108
112 itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
113
116 itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
117 itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
123 itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
124 itkBooleanMacro(AutoMinimumMaximum);
129 virtual void
131
132
133 // Change the access from protected to public to expose streaming option, a using statement can not be used due to
134 // limitations of wrapping.
135 void
136 SetNumberOfStreamDivisions(const unsigned int n) override
137 {
138 Superclass::SetNumberOfStreamDivisions(n);
139 }
140 unsigned int
142 {
143 return Superclass::GetNumberOfStreamDivisions();
144 }
145
146protected:
148 ~ImageToHistogramFilter() override = default;
149 void
150 PrintSelf(std::ostream & os, Indent indent) const override;
151
152 void
153 StreamedGenerateData(unsigned int inputRequestedRegionNumber) override;
154
155 void
157 void
159
162 using Superclass::MakeOutput;
164
165 /* Override method to disable streaming when the minimum and
166 * maximum need to be computed. */
167 unsigned int
169
170 void
172 virtual void
173 ThreadedComputeMinimumAndMaximum(const RegionType & inputRegionForThread);
174
175
176 virtual void
178
179 std::mutex m_Mutex{};
180
181 HistogramPointer m_MergeHistogram{};
182
185
186private:
187 void
190 HistogramSizeType & size);
191};
192} // end of namespace Statistics
193} // end of namespace itk
194
195#ifndef ITK_MANUAL_INSTANTIATION
196# include "itkImageToHistogramFilter.hxx"
197#endif
198
199#endif
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Decorates any "simple" data type (data types without smart pointers) with a DataObject API.
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:78
TMeasurement MeasurementType
Definition: itkHistogram.h:98
This class generates a histogram from an image.
void SetNumberOfStreamDivisions(const unsigned int n) override
void PrintSelf(std::ostream &os, Indent indent) const override
typename HistogramType::MeasurementType HistogramMeasurementType
virtual void ThreadedMergeHistogram(HistogramPointer &&histogram)
typename HistogramType::SizeType HistogramSizeType
void StreamedGenerateData(unsigned int inputRequestedRegionNumber) override
typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType
typename HistogramType::Pointer HistogramPointer
virtual void ThreadedComputeMinimumAndMaximum(const RegionType &inputRegionForThread)
void ThreadedStreamedGenerateData(const RegionType &) override
const HistogramType * GetOutput() const
unsigned int GetNumberOfStreamDivisions() const override
DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType) override
Make a DataObject of the correct type to used as the specified output.
typename NumericTraits< ValueType >::RealType ValueRealType
typename HistogramType::ConstPointer HistogramConstPointer
void ApplyMarginalScale(HistogramMeasurementVectorType &min, HistogramMeasurementVectorType &max, HistogramSizeType &size)
typename NumericTraits< PixelType >::ValueType ValueType
virtual void GraftOutput(DataObject *graft)
unsigned int GetNumberOfInputRequestedRegions() override
Return the actual number of regions to request upstream.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....