ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkMaskedMovingHistogramImageFilter.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 __itkMaskedMovingHistogramImageFilter_h
19 #define __itkMaskedMovingHistogramImageFilter_h
20 
22 #include <list>
23 #include <map>
24 #include <set>
25 
26 namespace itk
27 {
42 template< class TInputImage, class TMaskImage, class TOutputImage, class TKernel, class THistogram >
44  public MovingHistogramImageFilterBase< TInputImage, TOutputImage, TKernel >
45 {
46 public:
52 
54  itkNewMacro(Self);
55 
58 
60  typedef TInputImage InputImageType;
61  typedef TOutputImage OutputImageType;
62  typedef TMaskImage MaskImageType;
63  typedef typename TInputImage::RegionType RegionType;
64  typedef typename TInputImage::SizeType SizeType;
65  typedef typename TInputImage::IndexType IndexType;
66  typedef typename TInputImage::PixelType PixelType;
67  typedef typename TInputImage::OffsetType OffsetType;
68  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
69  typedef typename TOutputImage::PixelType OutputPixelType;
70  typedef typename TInputImage::PixelType InputPixelType;
71  typedef typename MaskImageType::PixelType MaskPixelType;
72  typedef THistogram HistogramType;
73 
75  void SetMaskImage(MaskImageType *input)
76  {
77  // Process object is not const-correct so the const casting is required.
78  this->SetNthInput( 1, const_cast< TMaskImage * >( input ) );
79  }
80 
82  MaskImageType * GetMaskImage()
83  {
84  return static_cast< MaskImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
85  }
86 
88  void SetInput1(InputImageType *input)
89  {
90  this->SetInput(input);
91  }
92 
94  void SetInput2(MaskImageType *input)
95  {
96  this->SetMaskImage(input);
97  }
98 
100  itkStaticConstMacro(ImageDimension, unsigned int,
101  TInputImage::ImageDimension);
102 
104  typedef TKernel KernelType;
105 
107  typedef typename KernelType::ConstIterator KernelIteratorType;
108 
110  typedef typename KernelType::SizeType RadiusType;
111 
112  typedef typename std::list< OffsetType > OffsetListType;
113 
114  typedef typename std::map< OffsetType, OffsetListType,
117 
119  MaskImageType * GetOutputMask();
120 
121  void AllocateOutputs();
122 
124  using Superclass::MakeOutput;
126 
127  itkSetMacro(FillValue, OutputPixelType);
128  itkGetConstMacro(FillValue, OutputPixelType);
129 
130  itkSetMacro(MaskValue, MaskPixelType);
131  itkGetConstMacro(MaskValue, MaskPixelType);
132 
133  itkSetMacro(BackgroundMaskValue, MaskPixelType);
134  itkGetConstMacro(BackgroundMaskValue, MaskPixelType);
135 
136  void SetGenerateOutputMask(bool);
137 
138  itkGetConstMacro(GenerateOutputMask, bool);
139 // itkBooleanMacro(GenerateOutputMask);
140 
142  virtual void ConfigureHistogram(THistogram &) {}
143 
144 protected:
147 
149  void ThreadedGenerateData(const OutputImageRegionType &
150  outputRegionForThread,
151  ThreadIdType threadId);
152 
153  void PrintSelf(std::ostream & os, Indent indent) const;
154 
155  void pushHistogram(HistogramType & histogram,
156  const OffsetListType *addedList,
157  const OffsetListType *removedList,
158  const RegionType & inputRegion,
159  const RegionType & kernRegion,
160  const InputImageType *inputImage,
161  const MaskImageType *maskImage,
162  const IndexType currentIdx);
163 
164 private:
165  MaskedMovingHistogramImageFilter(const Self &); //purposely not implemented
166  void operator=(const Self &); //purposely not implemented
167 
169 
171 
173 
175 }; // end of class
176 } // end namespace itk
177 
178 #ifndef ITK_MANUAL_INSTANTIATION
179 #include "itkMaskedMovingHistogramImageFilter.hxx"
180 #endif
181 
182 #endif
183