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 __itkMaskedMovingHistogramImageFilter_h 00019 #define __itkMaskedMovingHistogramImageFilter_h 00020 00021 #include "itkMovingHistogramImageFilterBase.h" 00022 #include <list> 00023 #include <map> 00024 #include <set> 00025 00026 namespace itk 00027 { 00042 template< class TInputImage, class TMaskImage, class TOutputImage, class TKernel, class THistogram > 00043 class ITK_EXPORT MaskedMovingHistogramImageFilter: 00044 public MovingHistogramImageFilterBase< TInputImage, TOutputImage, TKernel > 00045 { 00046 public: 00048 typedef MaskedMovingHistogramImageFilter Self; 00049 typedef MovingHistogramImageFilterBase< TInputImage, TOutputImage, TKernel > Superclass; 00050 typedef SmartPointer< Self > Pointer; 00051 typedef SmartPointer< const Self > ConstPointer; 00052 00054 itkNewMacro(Self); 00055 00057 itkTypeMacro(MaskedMovingHistogramImageFilter, MovingHistogramImageFilter); 00058 00060 typedef TInputImage InputImageType; 00061 typedef TOutputImage OutputImageType; 00062 typedef TMaskImage MaskImageType; 00063 typedef typename TInputImage::RegionType RegionType; 00064 typedef typename TInputImage::SizeType SizeType; 00065 typedef typename TInputImage::IndexType IndexType; 00066 typedef typename TInputImage::PixelType PixelType; 00067 typedef typename TInputImage::OffsetType OffsetType; 00068 typedef typename Superclass::OutputImageRegionType OutputImageRegionType; 00069 typedef typename TOutputImage::PixelType OutputPixelType; 00070 typedef typename TInputImage::PixelType InputPixelType; 00071 typedef typename MaskImageType::PixelType MaskPixelType; 00072 typedef THistogram HistogramType; 00073 00075 void SetMaskImage(MaskImageType *input) 00076 { 00077 // Process object is not const-correct so the const casting is required. 00078 this->SetNthInput( 1, const_cast< TMaskImage * >( input ) ); 00079 } 00080 00082 MaskImageType * GetMaskImage() 00083 { 00084 return static_cast< MaskImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) ); 00085 } 00086 00088 void SetInput1(InputImageType *input) 00089 { 00090 this->SetInput(input); 00091 } 00092 00094 void SetInput2(MaskImageType *input) 00095 { 00096 this->SetMaskImage(input); 00097 } 00098 00100 itkStaticConstMacro(ImageDimension, unsigned int, 00101 TInputImage::ImageDimension); 00102 00104 typedef TKernel KernelType; 00105 00107 typedef typename KernelType::ConstIterator KernelIteratorType; 00108 00110 typedef typename KernelType::SizeType RadiusType; 00111 00112 typedef typename std::list< OffsetType > OffsetListType; 00113 00114 typedef typename std::map< OffsetType, OffsetListType, 00115 typename Functor::OffsetLexicographicCompare< itkGetStaticConstMacro(ImageDimension) > > 00116 OffsetMapType; 00117 00119 MaskImageType * GetOutputMask(); 00120 00121 void AllocateOutputs(); 00122 00123 typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType; 00124 using Superclass::MakeOutput; 00125 DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx); 00126 00127 itkSetMacro(FillValue, OutputPixelType); 00128 itkGetConstMacro(FillValue, OutputPixelType); 00129 00130 itkSetMacro(MaskValue, MaskPixelType); 00131 itkGetConstMacro(MaskValue, MaskPixelType); 00132 00133 itkSetMacro(BackgroundMaskValue, MaskPixelType); 00134 itkGetConstMacro(BackgroundMaskValue, MaskPixelType); 00135 00136 void SetGenerateOutputMask(bool); 00137 00138 itkGetConstMacro(GenerateOutputMask, bool); 00139 // itkBooleanMacro(GenerateOutputMask); 00140 00142 virtual void ConfigureHistogram(THistogram &) {} 00143 00144 protected: 00145 MaskedMovingHistogramImageFilter(); 00146 ~MaskedMovingHistogramImageFilter() {} 00147 00149 void ThreadedGenerateData(const OutputImageRegionType & 00150 outputRegionForThread, 00151 ThreadIdType threadId); 00152 00153 void PrintSelf(std::ostream & os, Indent indent) const; 00154 00155 void pushHistogram(HistogramType & histogram, 00156 const OffsetListType *addedList, 00157 const OffsetListType *removedList, 00158 const RegionType & inputRegion, 00159 const RegionType & kernRegion, 00160 const InputImageType *inputImage, 00161 const MaskImageType *maskImage, 00162 const IndexType currentIdx); 00163 00164 private: 00165 MaskedMovingHistogramImageFilter(const Self &); //purposely not implemented 00166 void operator=(const Self &); //purposely not implemented 00167 00168 bool m_GenerateOutputMask; 00169 00170 OutputPixelType m_FillValue; 00171 00172 MaskPixelType m_MaskValue; 00173 00174 MaskPixelType m_BackgroundMaskValue; 00175 }; // end of class 00176 } // end namespace itk 00177 00178 #ifndef ITK_MANUAL_INSTANTIATION 00179 #include "itkMaskedMovingHistogramImageFilter.hxx" 00180 #endif 00181 00182 #endif 00183