ITK  4.13.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< typename TInputImage, typename TMaskImage, typename TOutputImage, typename TKernel, typename THistogram >
43 class ITK_TEMPLATE_EXPORT MaskedMovingHistogramImageFilter:
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;
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(const 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 
83  {
84  return static_cast< MaskImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
85  }
86 
88  void SetInput1(const InputImageType *input)
89  {
90  this->SetInput(input);
91  }
92 
94  void SetInput2(const 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 
111 
112  typedef typename std::list< OffsetType > OffsetListType;
113 
114  typedef typename std::map< OffsetType, OffsetListType,
117 
119  MaskImageType * GetOutputMask();
120 
121  void AllocateOutputs() ITK_OVERRIDE;
122 
124  using Superclass::MakeOutput;
125  DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
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) ITK_OVERRIDE;
152 
153  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
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  ITK_DISALLOW_COPY_AND_ASSIGN(MaskedMovingHistogramImageFilter);
166 
168 
170 
172 
174 }; // end of class
175 } // end namespace itk
176 
177 #ifndef ITK_MANUAL_INSTANTIATION
178 #include "itkMaskedMovingHistogramImageFilter.hxx"
179 #endif
180 
181 #endif
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Implements a generic moving histogram algorithm.
Order Offset instances lexicographically.
Definition: itkOffset.h:235
MovingHistogramImageFilterBase< TInputImage, TOutputImage, TKernel > Superclass
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
TOutputImage::PixelType OutputPixelType
Base class for all process objects that output image data.
TInputImage::OffsetType OffsetType
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
std::map< OffsetType, OffsetListType, typename Functor::OffsetLexicographicCompare< itkGetStaticConstMacro(ImageDimension) > > OffsetMapType
Superclass::OutputImageRegionType OutputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Implements a generic moving histogram algorithm.
Base class for all data objects in ITK.