ITK  5.0.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 
23 #include <list>
24 #include <map>
25 #include <set>
26 
27 namespace itk
28 {
43 template< typename TInputImage, typename TMaskImage, typename TOutputImage, typename TKernel, typename THistogram >
44 class ITK_TEMPLATE_EXPORT MaskedMovingHistogramImageFilter:
45  public MovingHistogramImageFilterBase< TInputImage, TOutputImage, TKernel >
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_ASSIGN(MaskedMovingHistogramImageFilter);
49 
55 
57  itkNewMacro(Self);
58 
61 
63  using InputImageType = TInputImage;
64  using OutputImageType = TOutputImage;
65  using MaskImageType = TMaskImage;
67  using SizeType = typename TInputImage::SizeType;
69  using PixelType = typename TInputImage::PixelType;
70  using OffsetType = typename TInputImage::OffsetType;
71  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
72  using OutputPixelType = typename TOutputImage::PixelType;
73  using InputPixelType = typename TInputImage::PixelType;
74  using MaskPixelType = typename MaskImageType::PixelType;
75  using HistogramType = THistogram;
76 
78  void SetMaskImage(const MaskImageType *input)
79  {
80  // Process object is not const-correct so the const casting is required.
81  this->SetNthInput( 1, const_cast< TMaskImage * >( input ) );
82  }
83 
86  {
87  return static_cast< MaskImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
88  }
89 
91  void SetInput1(const InputImageType *input)
92  {
93  this->SetInput(input);
94  }
95 
97  void SetInput2(const MaskImageType *input)
98  {
99  this->SetMaskImage(input);
100  }
101 
103  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
104 
106  using KernelType = TKernel;
107 
109  using KernelIteratorType = typename KernelType::ConstIterator;
110 
113 
114  using OffsetListType = typename std::list< OffsetType >;
115 
116  using OffsetMapType = typename std::map< OffsetType, OffsetListType,
118 
120  MaskImageType * GetOutputMask();
121 
122  void AllocateOutputs() override;
123 
125  using Superclass::MakeOutput;
126  DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override;
127 
128  itkSetMacro(FillValue, OutputPixelType);
129  itkGetConstMacro(FillValue, OutputPixelType);
130 
131  itkSetMacro(MaskValue, MaskPixelType);
132  itkGetConstMacro(MaskValue, MaskPixelType);
133 
134  itkSetMacro(BackgroundMaskValue, MaskPixelType);
135  itkGetConstMacro(BackgroundMaskValue, MaskPixelType);
136 
137  void SetGenerateOutputMask(bool);
138 
139  itkGetConstMacro(GenerateOutputMask, bool);
140  itkBooleanMacro(GenerateOutputMask);
141 
143  virtual void ConfigureHistogram(THistogram &) {}
144 
145 protected:
147  ~MaskedMovingHistogramImageFilter() override = default;
148 
150  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
151 
152 
153  void PrintSelf(std::ostream & os, Indent indent) const 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:
166 
168 
170 
172 }; // end of class
173 } // end namespace itk
174 
175 #ifndef ITK_MANUAL_INSTANTIATION
176 #include "itkMaskedMovingHistogramImageFilter.hxx"
177 #endif
178 
179 #endif
typename TInputImage::SizeType RadiusType
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
typename std::map< OffsetType, OffsetListType, Functor::LexicographicCompare > OffsetMapType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
typename TInputImage::IndexType IndexType
Implements a generic moving histogram algorithm.
typename TOutputImage::PixelType OutputPixelType
typename TInputImage::RegionType RegionType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename TInputImage::OffsetType OffsetType
typename KernelType::ConstIterator KernelIteratorType
typename OutputImageType::RegionType OutputImageRegionType
typename TInputImage::SizeType SizeType
TOutputImage OutputImageType
typename TInputImage::PixelType InputPixelType
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Order Index instances lexicographically.
Implements a generic moving histogram algorithm.
Base class for all data objects in ITK.