ITK  6.0.0
Insight Toolkit
itkHistogramMatchingImageFilter.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 itkHistogramMatchingImageFilter_h
19#define itkHistogramMatchingImageFilter_h
20
22#include "itkHistogram.h"
23#include "vnl/vnl_matrix.h"
24
25namespace itk
26{
72/* THistogramMeasurement -- The precision level for which to do
73 HistogramMeasurements */
74template <typename TInputImage, typename TOutputImage, typename THistogramMeasurement = typename TInputImage::PixelType>
75class ITK_TEMPLATE_EXPORT HistogramMatchingImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
76{
77public:
78 ITK_DISALLOW_COPY_AND_MOVE(HistogramMatchingImageFilter);
79
85
87 itkNewMacro(Self);
88
90 itkOverrideGetNameOfClassMacro(HistogramMatchingImageFilter);
91
93 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
94 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
95
98
100 using typename Superclass::InputImageType;
101 using typename Superclass::InputImagePointer;
102 using typename Superclass::InputImageConstPointer;
103 using typename Superclass::OutputImageType;
104 using typename Superclass::OutputImagePointer;
105
107 using InputPixelType = typename InputImageType::PixelType;
108 using OutputPixelType = typename OutputImageType::PixelType;
109
113
132 itkSetInputMacro(ReferenceHistogram, HistogramType);
133 itkGetInputMacro(ReferenceHistogram, HistogramType);
137 itkSetMacro(NumberOfHistogramLevels, SizeValueType);
138 itkGetConstMacro(NumberOfHistogramLevels, SizeValueType);
142 itkSetMacro(NumberOfMatchPoints, SizeValueType);
143 itkGetConstMacro(NumberOfMatchPoints, SizeValueType);
151 itkSetMacro(ThresholdAtMeanIntensity, bool);
152 itkGetConstMacro(ThresholdAtMeanIntensity, bool);
153 itkBooleanMacro(ThresholdAtMeanIntensity);
165 itkSetMacro(GenerateReferenceHistogramFromImage, bool);
166 itkGetConstMacro(GenerateReferenceHistogramFromImage, bool);
167 itkBooleanMacro(GenerateReferenceHistogramFromImage);
171 void
173
177 itkGetModifiableObjectMacro(SourceHistogram, HistogramType);
178 itkGetModifiableObjectMacro(OutputHistogram, HistogramType);
181#ifdef ITK_USE_CONCEPT_CHECKING
182 // Begin concept checking
183 itkConceptMacro(IntConvertibleToInputCheck, (Concept::Convertible<int, InputPixelType>));
185 itkConceptMacro(DoubleConvertibleToInputCheck, (Concept::Convertible<double, InputPixelType>));
186 itkConceptMacro(DoubleConvertibleToOutputCheck, (Concept::Convertible<double, OutputPixelType>));
187 itkConceptMacro(InputConvertibleToDoubleCheck, (Concept::Convertible<InputPixelType, double>));
188 itkConceptMacro(OutputConvertibleToDoubleCheck, (Concept::Convertible<OutputPixelType, double>));
190 // End concept checking
191#endif
192
193protected:
195 ~HistogramMatchingImageFilter() override = default;
196 void
197 PrintSelf(std::ostream & os, Indent indent) const override;
198
199 void
201
202 void
204
205 void
206 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
207
208
214 void
215 VerifyInputInformation() const override
216 {}
217
218 void
219 VerifyPreconditions() const override;
220
222 void
224 THistogramMeasurement & minValue,
225 THistogramMeasurement & maxValue,
226 THistogramMeasurement & meanValue);
227
232 void
234 HistogramType * histogram,
235 const THistogramMeasurement minHistogramValidValue,
236 const THistogramMeasurement maxHistogramValidValue,
237 const THistogramMeasurement imageTrueMinValue,
238 const THistogramMeasurement imageTrueMaxValue);
239
240private:
241 SizeValueType m_NumberOfHistogramLevels{ 256 };
242 SizeValueType m_NumberOfMatchPoints{ 1 };
243 bool m_ThresholdAtMeanIntensity{ true };
244
245 THistogramMeasurement m_SourceMinValue{};
246 THistogramMeasurement m_SourceMaxValue{};
247
248 THistogramMeasurement m_ReferenceMinValue{};
249 THistogramMeasurement m_ReferenceMaxValue{};
250
251 HistogramPointer m_SourceHistogram{};
252 HistogramPointer m_OutputHistogram{};
253
254 using TableType = vnl_matrix<double>;
255 TableType m_QuantileTable{};
256
257 using GradientArrayType = vnl_vector<double>;
258 GradientArrayType m_Gradients{};
259 double m_LowerGradient{ 0.0 };
260 double m_UpperGradient{ 0.0 };
261 bool m_GenerateReferenceHistogramFromImage{ true };
262};
263} // end namespace itk
264
265#ifndef ITK_MANUAL_INSTANTIATION
266# include "itkHistogramMatchingImageFilter.hxx"
267#endif
268
269#endif
Normalize the grayscale values for a source image by matching the shape of the source image histogram...
typename HistogramType::Pointer HistogramPointer
~HistogramMatchingImageFilter() override=default
void GenerateInputRequestedRegion() override
itkSetInputMacro(ReferenceHistogram, HistogramType)
void VerifyPreconditions() const override
Verifies that the process object has been configured correctly, that all required inputs are set,...
void ConstructHistogramFromIntensityRange(const InputImageType *image, HistogramType *histogram, const THistogramMeasurement minHistogramValidValue, const THistogramMeasurement maxHistogramValidValue, const THistogramMeasurement imageTrueMinValue, const THistogramMeasurement imageTrueMaxValue)
typename OutputImageType::PixelType OutputPixelType
itkSetInputMacro(SourceImage, InputImageType)
void ComputeMinMaxMean(const InputImageType *image, THistogramMeasurement &minValue, THistogramMeasurement &maxValue, THistogramMeasurement &meanValue)
void PrintSelf(std::ostream &os, Indent indent) const override
itkGetInputMacro(SourceImage, InputImageType)
typename InputImageType::PixelType InputPixelType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
itkGetInputMacro(ReferenceImage, InputImageType)
itkSetInputMacro(ReferenceImage, InputImageType)
void AfterThreadedGenerateData() override
void BeforeThreadedGenerateData() override
itkGetInputMacro(ReferenceHistogram, HistogramType)
Base class for all process objects that output image data.
typename OutputImageType::RegionType OutputImageRegionType
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:78
SmartPointer< Self > Pointer
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86