ITK
4.1.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 __itkBilateralImageFilter_h 00019 #define __itkBilateralImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkFixedArray.h" 00023 #include "itkNeighborhoodIterator.h" 00024 #include "itkNeighborhood.h" 00025 00026 namespace itk 00027 { 00074 template< class TInputImage, class TOutputImage > 00075 class ITK_EXPORT BilateralImageFilter: 00076 public ImageToImageFilter< TInputImage, TOutputImage > 00077 { 00078 public: 00080 typedef BilateralImageFilter Self; 00081 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00082 typedef SmartPointer< Self > Pointer; 00083 typedef SmartPointer< const Self > ConstPointer; 00084 00086 itkNewMacro(Self); 00087 00089 itkTypeMacro(BilateralImageFilter, ImageToImageFilter); 00090 00092 typedef TInputImage InputImageType; 00093 typedef TOutputImage OutputImageType; 00094 00096 typedef typename Superclass::OutputImageRegionType OutputImageRegionType; 00097 00100 typedef typename TOutputImage::PixelType OutputPixelType; 00101 typedef typename TOutputImage::InternalPixelType OutputInternalPixelType; 00102 typedef typename NumericTraits< OutputPixelType >::RealType OutputPixelRealType; 00103 typedef typename TInputImage::PixelType InputPixelType; 00104 typedef typename TInputImage::InternalPixelType InputInternalPixelType; 00105 00108 itkStaticConstMacro(ImageDimension, unsigned int, 00109 TOutputImage::ImageDimension); 00110 00112 typedef FixedArray< double, itkGetStaticConstMacro(ImageDimension) > ArrayType; 00113 00115 typedef ConstNeighborhoodIterator< TInputImage > NeighborhoodIteratorType; 00116 00118 typedef 00119 Neighborhood< double, itkGetStaticConstMacro(ImageDimension) > KernelType; 00120 typedef typename KernelType::SizeType SizeType; 00121 typedef typename KernelType::SizeValueType SizeValueType; 00122 00124 typedef typename KernelType::Iterator KernelIteratorType; 00125 typedef typename KernelType::ConstIterator KernelConstIteratorType; 00126 00128 typedef 00129 Image< double, itkGetStaticConstMacro(ImageDimension) > GaussianImageType; 00130 00134 itkSetMacro(DomainSigma, ArrayType); 00135 itkGetConstMacro(DomainSigma, const ArrayType); 00136 itkSetMacro(RangeSigma, double); 00137 itkGetConstMacro(RangeSigma, double); 00138 itkGetConstMacro(FilterDimensionality, unsigned int); 00139 itkSetMacro(FilterDimensionality, unsigned int); 00141 00144 void SetDomainSigma(const double v) 00145 { 00146 m_DomainSigma.Fill(v); 00147 } 00148 00154 itkBooleanMacro(AutomaticKernelSize); 00155 itkGetConstMacro(AutomaticKernelSize, bool); 00156 itkSetMacro(AutomaticKernelSize, bool); 00158 00161 void SetRadius(const SizeValueType); 00162 00163 itkSetMacro(Radius, SizeType); 00164 itkGetConstReferenceMacro(Radius, SizeType); 00165 00169 itkSetMacro(NumberOfRangeGaussianSamples, unsigned long); 00170 itkGetConstMacro(NumberOfRangeGaussianSamples, unsigned long); 00172 00173 #ifdef ITK_USE_CONCEPT_CHECKING 00174 00175 itkConceptMacro( OutputHasNumericTraitsCheck, 00176 ( Concept::HasNumericTraits< OutputPixelType > ) ); 00177 00179 #endif 00180 protected: 00181 00184 BilateralImageFilter() 00185 { 00186 m_Radius.Fill(1); 00187 m_AutomaticKernelSize = true; 00188 m_DomainSigma.Fill(4.0); 00189 m_RangeSigma = 50.0; 00190 m_FilterDimensionality = ImageDimension; 00191 m_NumberOfRangeGaussianSamples = 100; 00192 m_DynamicRange = 0.0; 00193 m_DynamicRangeUsed = 0.0; 00194 m_DomainMu = 2.5; // keep small to keep kernels small 00195 m_RangeMu = 4.0; // can be bigger then DomainMu since we only 00196 // index into a single table 00197 } 00199 00200 virtual ~BilateralImageFilter() {} 00201 void PrintSelf(std::ostream & os, Indent indent) const; 00202 00204 void BeforeThreadedGenerateData(); 00205 00208 void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, 00209 ThreadIdType threadId); 00210 00217 virtual void GenerateInputRequestedRegion() 00218 throw( InvalidRequestedRegionError ); 00219 00220 private: 00221 BilateralImageFilter(const Self &); //purposely not implemented 00222 void operator=(const Self &); //purposely not implemented 00223 00226 double m_RangeSigma; 00227 00230 ArrayType m_DomainSigma; 00231 00234 double m_DomainMu; 00235 double m_RangeMu; 00236 00238 unsigned int m_FilterDimensionality; 00239 00241 KernelType m_GaussianKernel; 00242 SizeType m_Radius; 00243 bool m_AutomaticKernelSize; 00244 00246 unsigned long m_NumberOfRangeGaussianSamples; 00247 double m_DynamicRange; 00248 double m_DynamicRangeUsed; 00249 std::vector< double > m_RangeGaussianTable; 00250 }; 00251 } // end namespace itk 00252 00253 #ifndef ITK_MANUAL_INSTANTIATION 00254 #include "itkBilateralImageFilter.hxx" 00255 #endif 00256 00257 #endif 00258