ITK  5.2.0
Insight Toolkit
itkLabelMapFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkLabelMapFilter_h
29 #define itkLabelMapFilter_h
30 
31 #include "itkImageToImageFilter.h"
32 #include <mutex>
33 
34 namespace itk
35 {
56 template <typename TInputImage, typename TOutputImage>
57 class ITK_TEMPLATE_EXPORT LabelMapFilter : public ImageToImageFilter<TInputImage, TOutputImage>
58 {
59 public:
60  ITK_DISALLOW_COPY_AND_MOVE(LabelMapFilter);
61 
67 
69  itkTypeMacro(LabelMapFilter, ImageToImageFilter);
70 
72  itkNewMacro(Self);
73 
75  using InputImageType = typename Superclass::InputImageType;
76  using InputImagePointer = typename Superclass::InputImagePointer;
77  using InputImageConstPointer = typename Superclass::InputImageConstPointer;
78  using InputImageRegionType = typename Superclass::InputImageRegionType;
79  using InputImagePixelType = typename Superclass::InputImagePixelType;
80  using LabelObjectType = typename InputImageType::LabelObjectType;
81 
82  using OutputImageType = TOutputImage;
83  using OutputImagePointer = typename OutputImageType::Pointer;
84  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
86  using OutputImagePixelType = typename OutputImageType::PixelType;
87 
89  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
90  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
91 
95  void
96  GenerateInputRequestedRegion() override;
97 
99  void
100  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
101 
102 protected:
103  LabelMapFilter();
104  ~LabelMapFilter() override = default;
105 
106  void
107  BeforeThreadedGenerateData() override;
108 
109  void
110  AfterThreadedGenerateData() override;
111 
112  void
113  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
114 
115  // derived classes call this as inherited so we must delegate to DynamicThreadedGenerateData
116  void
117  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType) override
118  {
119  Self::DynamicThreadedGenerateData(outputRegionForThread);
120  }
121 
122  virtual void
123  ThreadedProcessLabelObject(LabelObjectType * labelObject);
124 
129  virtual InputImageType *
131  {
132  return static_cast<InputImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(0)));
133  }
134 
136 
137 private:
138  typename InputImageType::Iterator m_LabelObjectIterator;
139 };
140 } // end namespace itk
141 
142 #ifndef ITK_MANUAL_INSTANTIATION
143 # include "itkLabelMapFilter.hxx"
144 #endif
145 
146 #endif
itk::LabelMapFilter::GetLabelMap
virtual InputImageType * GetLabelMap()
Definition: itkLabelMapFilter.h:130
itk::LabelMapFilter< TImage, TImage >::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapFilter.h:84
itk::ImageSource< TImage >::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::SmartPointer< Self >
itk::LabelMapFilter< TImage, TImage >::LabelObjectType
typename InputImageType::LabelObjectType LabelObjectType
Definition: itkLabelMapFilter.h:80
itk::ImageToImageFilter< TImage, TImage >::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ImageToImageFilter< TImage, TImage >::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:57
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapFilter::ThreadedGenerateData
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType) override
Definition: itkLabelMapFilter.h:117
itk::LabelMapFilter::m_LabelObjectContainerLock
std::mutex m_LabelObjectContainerLock
Definition: itkLabelMapFilter.h:135
itk::ImageToImageFilter< TImage, TImage >::InputImageType
TImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::ImageSource< TImage >::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ImageSource< TImage >::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapFilter::m_LabelObjectIterator
InputImageType::Iterator m_LabelObjectIterator
Definition: itkLabelMapFilter.h:138
itk::ImageToImageFilter< TImage, TImage >::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::ImageToImageFilter< TImage, TImage >::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::ImageSource< TImage >::OutputImageType
TImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293