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 {
57 template <typename TInputImage, typename TOutputImage>
58 class ITK_TEMPLATE_EXPORT LabelMapFilter : public ImageToImageFilter<TInputImage, TOutputImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapFilter);
62 
68 
70  itkTypeMacro(LabelMapFilter, ImageToImageFilter);
71 
73  itkNewMacro(Self);
74 
76  using InputImageType = typename Superclass::InputImageType;
77  using InputImagePointer = typename Superclass::InputImagePointer;
78  using InputImageConstPointer = typename Superclass::InputImageConstPointer;
79  using InputImageRegionType = typename Superclass::InputImageRegionType;
80  using InputImagePixelType = typename Superclass::InputImagePixelType;
81  using LabelObjectType = typename InputImageType::LabelObjectType;
82 
83  using OutputImageType = TOutputImage;
84  using OutputImagePointer = typename OutputImageType::Pointer;
85  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
87  using OutputImagePixelType = typename OutputImageType::PixelType;
88 
90  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
91  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
92 
96  void
97  GenerateInputRequestedRegion() override;
98 
100  void
101  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
102 
103 protected:
104  LabelMapFilter();
105  ~LabelMapFilter() override = default;
106 
107  void
108  BeforeThreadedGenerateData() override;
109 
110  void
111  AfterThreadedGenerateData() override;
112 
113  void
114  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
115 
116  // derived classes call this as inherited so we must delegate to DynamicThreadedGenerateData
117  void
118  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType) override
119  {
120  Self::DynamicThreadedGenerateData(outputRegionForThread);
121  }
122 
123  virtual void
124  ThreadedProcessLabelObject(LabelObjectType * labelObject);
125 
130  virtual InputImageType *
132  {
133  return static_cast<InputImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(0)));
134  }
135 
137 
138 private:
139  typename InputImageType::Iterator m_LabelObjectIterator;
140 };
141 } // end namespace itk
142 
143 #ifndef ITK_MANUAL_INSTANTIATION
144 # include "itkLabelMapFilter.hxx"
145 #endif
146 
147 #endif
itk::LabelMapFilter::GetLabelMap
virtual InputImageType * GetLabelMap()
Definition: itkLabelMapFilter.h:131
itk::LabelMapFilter< TImage, TImage >::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapFilter.h:85
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:81
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:58
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:118
itk::LabelMapFilter::m_LabelObjectContainerLock
std::mutex m_LabelObjectContainerLock
Definition: itkLabelMapFilter.h:136
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:139
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