ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkHistogramMatchingImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 
21 #include "itkImageToImageFilter.h"
22 #include "itkHistogram.h"
23 #include "vnl/vnl_matrix.h"
24 
25 namespace itk
26 {
65 /* THistogramMeasurement -- The precision level for which to do
66  HistogramMeasurmenets */
67 template< typename TInputImage, typename TOutputImage, typename THistogramMeasurement = typename TInputImage::PixelType >
68 class ITK_TEMPLATE_EXPORT HistogramMatchingImageFilter:
69  public ImageToImageFilter< TInputImage, TOutputImage >
70 {
71 public:
77 
79  itkNewMacro(Self);
80 
83 
85  itkStaticConstMacro(ImageDimension, unsigned int,
86  TInputImage::ImageDimension);
87  itkStaticConstMacro(OutputImageDimension, unsigned int,
88  TOutputImage::ImageDimension);
90 
92  typedef typename TOutputImage::RegionType OutputImageRegionType;
93 
96  typedef typename Superclass::InputImagePointer InputImagePointer;
97  typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
98  typedef typename Superclass::OutputImageType OutputImageType;
99  typedef typename Superclass::OutputImagePointer OutputImagePointer;
100 
102  typedef typename InputImageType::PixelType InputPixelType;
103  typedef typename OutputImageType::PixelType OutputPixelType;
104 
108 
110  void SetSourceImage(const InputImageType *source)
111  { this->SetInput(source); }
113  { return this->GetInput(); }
115 
117  void SetReferenceImage(const InputImageType *reference);
118 
119  const InputImageType * GetReferenceImage();
120 
122  itkSetMacro(NumberOfHistogramLevels, SizeValueType);
123  itkGetConstMacro(NumberOfHistogramLevels, SizeValueType);
125 
127  itkSetMacro(NumberOfMatchPoints, SizeValueType);
128  itkGetConstMacro(NumberOfMatchPoints, SizeValueType);
130 
136  itkSetMacro(ThresholdAtMeanIntensity, bool);
137  itkGetConstMacro(ThresholdAtMeanIntensity, bool);
138  itkBooleanMacro(ThresholdAtMeanIntensity);
140 
142  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
143 
147  itkGetModifiableObjectMacro(SourceHistogram, HistogramType);
148  itkGetModifiableObjectMacro(ReferenceHistogram, HistogramType);
149  itkGetModifiableObjectMacro(OutputHistogram, HistogramType);
151 
152 #ifdef ITK_USE_CONCEPT_CHECKING
153  // Begin concept checking
154  itkConceptMacro( IntConvertibleToInputCheck,
156  itkConceptMacro( SameDimensionCheck,
158  itkConceptMacro( DoubleConvertibleToInputCheck,
160  itkConceptMacro( DoubleConvertibleToOutputCheck,
162  itkConceptMacro( InputConvertibleToDoubleCheck,
164  itkConceptMacro( OutputConvertibleToDoubleCheck,
166  itkConceptMacro( SameTypeCheck,
168  // End concept checking
169 #endif
170 
171 protected:
174  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
175 
176  void BeforeThreadedGenerateData() ITK_OVERRIDE;
177 
178  void AfterThreadedGenerateData() ITK_OVERRIDE;
179 
180  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
181  ThreadIdType threadId) ITK_OVERRIDE;
182 
188  virtual void VerifyInputInformation() ITK_OVERRIDE {}
189 
191  void ComputeMinMaxMean(const InputImageType *image,
192  THistogramMeasurement & minValue,
193  THistogramMeasurement & maxValue,
194  THistogramMeasurement & meanValue);
195 
197  void ConstructHistogram(const InputImageType *image,
198  HistogramType *histogram, const THistogramMeasurement minValue,
199  const THistogramMeasurement maxValue);
200 
201 private:
202  ITK_DISALLOW_COPY_AND_ASSIGN(HistogramMatchingImageFilter);
203 
207 
211 
212  THistogramMeasurement m_SourceMinValue;
213  THistogramMeasurement m_SourceMaxValue;
214  THistogramMeasurement m_SourceMeanValue;
215  THistogramMeasurement m_ReferenceMinValue;
216  THistogramMeasurement m_ReferenceMaxValue;
217  THistogramMeasurement m_ReferenceMeanValue;
218  THistogramMeasurement m_OutputMinValue;
219  THistogramMeasurement m_OutputMaxValue;
220  THistogramMeasurement m_OutputMeanValue;
221 
225 
226  typedef vnl_matrix< double > TableType;
228 
229  typedef vnl_vector< double > GradientArrayType;
233 };
234 } // end namespace itk
235 
236 #ifndef ITK_MANUAL_INSTANTIATION
237 #include "itkHistogramMatchingImageFilter.hxx"
238 #endif
239 
240 #endif
Superclass::OutputImagePointer OutputImagePointer
ImageToImageFilter< TInputImage, TOutputImage > Superclass
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
Superclass::InputImagePointer InputImagePointer
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
Base class for filters that take an image as input and produce an image as output.
void SetSourceImage(const InputImageType *source)
Normalize the grayscale values between two images by histogram matching.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
#define itkConceptMacro(name, concept)
Statistics::Histogram< THistogramMeasurement > HistogramType
Superclass::InputImageConstPointer InputImageConstPointer