ITK  4.6.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 >
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 
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(void);
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();
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;
175 
177 
179 
180  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
181  ThreadIdType threadId);
182 
188  virtual void VerifyInputInformation() {}
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  HistogramMatchingImageFilter(const Self &); //purposely not implemented
203  void operator=(const Self &); //purposely not implemented
204 
208 
212 
213  THistogramMeasurement m_SourceMinValue;
214  THistogramMeasurement m_SourceMaxValue;
215  THistogramMeasurement m_SourceMeanValue;
216  THistogramMeasurement m_ReferenceMinValue;
217  THistogramMeasurement m_ReferenceMaxValue;
218  THistogramMeasurement m_ReferenceMeanValue;
219  THistogramMeasurement m_OutputMinValue;
220  THistogramMeasurement m_OutputMaxValue;
221  THistogramMeasurement m_OutputMeanValue;
222 
226 
227  typedef vnl_matrix< double > TableType;
229 
230  typedef vnl_vector< double > GradientArrayType;
234 };
235 } // end namespace itk
236 
237 #ifndef ITK_MANUAL_INSTANTIATION
238 #include "itkHistogramMatchingImageFilter.hxx"
239 #endif
240 
241 #endif
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
InputImageType::ConstPointer InputImageConstPointer
void SetReferenceImage(const InputImageType *reference)
InputImageType::Pointer InputImagePointer
Superclass::OutputImagePointer OutputImagePointer
ImageToImageFilter< TInputImage, TOutputImage > Superclass
This class stores measurement vectors in the context of n-dimensional histogram.
Definition: itkHistogram.h:77
void ComputeMinMaxMean(const InputImageType *image, THistogramMeasurement &minValue, THistogramMeasurement &maxValue, THistogramMeasurement &meanValue)
Superclass::InputImagePointer InputImagePointer
virtual void GenerateInputRequestedRegion()
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
void PrintSelf(std::ostream &os, Indent indent) const
const InputImageType * GetReferenceImage(void)
virtual void SetInput(const InputImageType *image)
OutputImageType::Pointer OutputImagePointer
const InputImageType * GetInput(void) const
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.
void ConstructHistogram(const InputImageType *image, HistogramType *histogram, const THistogramMeasurement minValue, const THistogramMeasurement maxValue)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TOutputImage OutputImageType
#define itkConceptMacro(name, concept)
Statistics::Histogram< THistogramMeasurement > HistogramType
Superclass::InputImageConstPointer InputImageConstPointer
unsigned int ThreadIdType
Definition: itkIntTypes.h:159