ITK  6.0.0
Insight Toolkit
itkLabelMapOverlayImageFilter.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 * https://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 itkLabelMapOverlayImageFilter_h
19#define itkLabelMapOverlayImageFilter_h
20
21#include "itkLabelMapFilter.h"
23#include "itkRGBPixel.h"
24
25namespace itk
26{
27
56template <typename TLabelMap,
57 typename TFeatureImage,
58 typename TOutputImage = Image<RGBPixel<typename TFeatureImage::PixelType>, TFeatureImage::ImageDimension>>
59class ITK_TEMPLATE_EXPORT LabelMapOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
60{
61public:
62 ITK_DISALLOW_COPY_AND_MOVE(LabelMapOverlayImageFilter);
63
69
71 using LabelMapType = TLabelMap;
75 using LabelMapPixelType = typename LabelMapType::PixelType;
76 using LabelObjectType = typename LabelMapType::LabelObjectType;
77 using LabelType = typename LabelObjectType::LabelType;
78 using LengthType = typename LabelObjectType::LengthType;
79
80 using FeatureImageType = TFeatureImage;
84 using FeatureImagePixelType = typename FeatureImageType::PixelType;
85
86 using OutputImageType = TOutputImage;
90 using OutputImagePixelType = typename OutputImageType::PixelType;
94
97
99 static constexpr unsigned int InputImageDimension = TLabelMap::ImageDimension;
100 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
101 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
102
104 itkNewMacro(Self);
105
107 itkOverrideGetNameOfClassMacro(LabelMapOverlayImageFilter);
108
110 void
111 SetFeatureImage(const TFeatureImage * input)
112 {
113 // Process object is not const-correct so the const casting is required.
114 this->SetNthInput(1, const_cast<TFeatureImage *>(input));
115 }
116
118 const FeatureImageType *
120 {
121 return static_cast<FeatureImageType *>((this->ProcessObject::GetInput(1)));
122 }
123
125 void
126 SetInput1(const TLabelMap * input)
127 {
128 this->SetInput(input);
129 }
130
132 void
133 SetInput2(const TFeatureImage * input)
134 {
135 this->SetFeatureImage(input);
136 }
137
141 itkSetMacro(Opacity, double);
142 itkGetConstReferenceMacro(Opacity, double);
148 virtual void
149 SetFunctor(const FunctorType & functor)
150 {
151 if (m_Functor != functor)
152 {
153 m_Functor = functor;
154 this->Modified();
155 }
156 }
159 {
160 return m_Functor;
161 }
162 const FunctorType &
164 {
165 return m_Functor;
166 }
169protected:
171 ~LabelMapOverlayImageFilter() override = default;
172
176 void
178
180 void
181 EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
182
183 void
184 GenerateData() override;
185
186 void
187 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
188
189 // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
190 void
192 {
193 Superclass::DynamicThreadedGenerateData(outputRegion);
194 }
195
196 void
198
199 void
201
202 void
203 PrintSelf(std::ostream & os, Indent indent) const override;
204
205private:
206 double m_Opacity{};
207 FunctorType m_Functor{};
208
209}; // end of class
210
211} // end namespace itk
212
213#ifndef ITK_MANUAL_INSTANTIATION
214# include "itkLabelMapOverlayImageFilter.hxx"
215#endif
216
217#endif
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for filters that take an image as input and overwrite that image as the output.
Apply a colormap to a label map and superimpose it on an image.
typename OutputImageType::ConstPointer OutputImageConstPointer
typename OutputImageType::PixelType OutputImagePixelType
typename LabelMapType::ConstPointer LabelMapConstPointer
void SetFeatureImage(const TFeatureImage *input)
typename LabelMapType::RegionType LabelMapRegionType
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
typename LabelObjectType::LengthType LengthType
typename LabelMapType::Pointer LabelMapPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
typename LabelObjectType::LabelType LabelType
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::RegionType RegionType
typename LabelMapType::PixelType LabelMapPixelType
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
void GenerateInputRequestedRegion() override
virtual void SetFunctor(const FunctorType &functor)
void GenerateOutputInformation() override
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
typename OutputImageType::Pointer OutputImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
typename FeatureImageType::RegionType FeatureImageRegionType
void EnlargeOutputRequestedRegion(DataObject *) override
typename OutputImageType::SizeType SizeType
typename LabelMapType::LabelObjectType LabelObjectType
typename OutputImageType::IndexType IndexType
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
typename FeatureImageType::PixelType FeatureImagePixelType
~LabelMapOverlayImageFilter() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
void SetInput2(const TFeatureImage *input)
Light weight base class for most itk classes.
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....