![]() |
ITK
4.2.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkHistogramMatchingImageFilter_h 00019 #define __itkHistogramMatchingImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkHistogram.h" 00023 #include "vnl/vnl_matrix.h" 00024 00025 namespace itk 00026 { 00065 /* THistogramMeasurement -- The precision level for which to do 00066 HistogramMeasurmenets */ 00067 template< class TInputImage, class TOutputImage, class THistogramMeasurement = typename TInputImage::PixelType > 00068 class ITK_EXPORT HistogramMatchingImageFilter: 00069 public ImageToImageFilter< TInputImage, TOutputImage > 00070 { 00071 public: 00073 typedef HistogramMatchingImageFilter Self; 00074 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00075 typedef SmartPointer< Self > Pointer; 00076 typedef SmartPointer< const Self > ConstPointer; 00077 00079 itkNewMacro(Self); 00080 00082 itkTypeMacro(HistogramMatchingImageFilter, ImageToImageFilter); 00083 00085 itkStaticConstMacro(ImageDimension, unsigned int, 00086 TInputImage::ImageDimension); 00087 itkStaticConstMacro(OutputImageDimension, unsigned int, 00088 TOutputImage::ImageDimension); 00090 00092 typedef typename TOutputImage::RegionType OutputImageRegionType; 00093 00095 typedef typename Superclass::InputImageType InputImageType; 00096 typedef typename Superclass::InputImagePointer InputImagePointer; 00097 typedef typename Superclass::InputImageConstPointer InputImageConstPointer; 00098 typedef typename Superclass::OutputImageType OutputImageType; 00099 typedef typename Superclass::OutputImagePointer OutputImagePointer; 00100 00102 typedef typename InputImageType::PixelType InputPixelType; 00103 typedef typename OutputImageType::PixelType OutputPixelType; 00104 00106 typedef Statistics::Histogram< THistogramMeasurement > HistogramType; 00107 typedef typename HistogramType::Pointer HistogramPointer; 00108 00110 void SetSourceImage(const InputImageType *source) 00111 { this->SetInput(source); } 00112 const InputImageType * GetSourceImage(void) 00113 { return this->GetInput(); } 00115 00117 void SetReferenceImage(const InputImageType *reference); 00118 00119 const InputImageType * GetReferenceImage(void); 00120 00122 itkSetMacro(NumberOfHistogramLevels, SizeValueType); 00123 itkGetConstMacro(NumberOfHistogramLevels, SizeValueType); 00125 00127 itkSetMacro(NumberOfMatchPoints, SizeValueType); 00128 itkGetConstMacro(NumberOfMatchPoints, SizeValueType); 00130 00136 itkSetMacro(ThresholdAtMeanIntensity, bool); 00137 itkGetConstMacro(ThresholdAtMeanIntensity, bool); 00138 itkBooleanMacro(ThresholdAtMeanIntensity); 00140 00142 virtual void GenerateInputRequestedRegion(); 00143 00147 itkGetObjectMacro(SourceHistogram, HistogramType); 00148 itkGetObjectMacro(ReferenceHistogram, HistogramType); 00149 itkGetObjectMacro(OutputHistogram, HistogramType); 00151 00152 #ifdef ITK_USE_CONCEPT_CHECKING 00153 00154 itkConceptMacro( IntConvertibleToInputCheck, 00155 ( Concept::Convertible< int, InputPixelType > ) ); 00156 itkConceptMacro( SameDimensionCheck, 00157 ( Concept::SameDimension< ImageDimension, OutputImageDimension > ) ); 00158 itkConceptMacro( DoubleConvertibleToInputCheck, 00159 ( Concept::Convertible< double, InputPixelType > ) ); 00160 itkConceptMacro( DoubleConvertibleToOutputCheck, 00161 ( Concept::Convertible< double, OutputPixelType > ) ); 00162 itkConceptMacro( InputConvertibleToDoubleCheck, 00163 ( Concept::Convertible< InputPixelType, double > ) ); 00164 itkConceptMacro( OutputConvertibleToDoubleCheck, 00165 ( Concept::Convertible< OutputPixelType, double > ) ); 00166 itkConceptMacro( SameTypeCheck, 00167 ( Concept::SameType< InputPixelType, OutputPixelType > ) ); 00168 00170 #endif 00171 protected: 00172 HistogramMatchingImageFilter(); 00173 ~HistogramMatchingImageFilter() {} 00174 void PrintSelf(std::ostream & os, Indent indent) const; 00176 00177 void BeforeThreadedGenerateData(); 00178 00179 void AfterThreadedGenerateData(); 00180 00181 void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, 00182 ThreadIdType threadId); 00183 00189 virtual void VerifyInputInformation() {} 00190 00192 void ComputeMinMaxMean(const InputImageType *image, 00193 THistogramMeasurement & minValue, 00194 THistogramMeasurement & maxValue, 00195 THistogramMeasurement & meanValue); 00196 00198 void ConstructHistogram(const InputImageType *image, 00199 HistogramType *histogram, const THistogramMeasurement minValue, 00200 const THistogramMeasurement maxValue); 00201 00202 private: 00203 HistogramMatchingImageFilter(const Self &); //purposely not implemented 00204 void operator=(const Self &); //purposely not implemented 00205 00206 SizeValueType m_NumberOfHistogramLevels; 00207 SizeValueType m_NumberOfMatchPoints; 00208 bool m_ThresholdAtMeanIntensity; 00209 00210 InputPixelType m_SourceIntensityThreshold; 00211 InputPixelType m_ReferenceIntensityThreshold; 00212 OutputPixelType m_OutputIntensityThreshold; 00213 00214 THistogramMeasurement m_SourceMinValue; 00215 THistogramMeasurement m_SourceMaxValue; 00216 THistogramMeasurement m_SourceMeanValue; 00217 THistogramMeasurement m_ReferenceMinValue; 00218 THistogramMeasurement m_ReferenceMaxValue; 00219 THistogramMeasurement m_ReferenceMeanValue; 00220 THistogramMeasurement m_OutputMinValue; 00221 THistogramMeasurement m_OutputMaxValue; 00222 THistogramMeasurement m_OutputMeanValue; 00223 00224 HistogramPointer m_SourceHistogram; 00225 HistogramPointer m_ReferenceHistogram; 00226 HistogramPointer m_OutputHistogram; 00227 00228 typedef vnl_matrix< double > TableType; 00229 TableType m_QuantileTable; 00230 00231 typedef vnl_vector< double > GradientArrayType; 00232 GradientArrayType m_Gradients; 00233 double m_LowerGradient; 00234 double m_UpperGradient; 00235 }; 00236 } // end namespace itk 00237 00238 #ifndef ITK_MANUAL_INSTANTIATION 00239 #include "itkHistogramMatchingImageFilter.hxx" 00240 #endif 00241 00242 #endif 00243
1.7.6.1