ITK  5.4.0
Insight Toolkit
itkLabelMapContourOverlayImageFilter.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 itkLabelMapContourOverlayImageFilter_h
19#define itkLabelMapContourOverlayImageFilter_h
20
21#include "itkLabelMapFilter.h"
23#include "itkRGBPixel.h"
24
25namespace itk
26{
27
57template <typename TLabelMap,
58 typename TFeatureImage,
59 typename TOutputImage = Image<RGBPixel<typename TFeatureImage::PixelType>, TFeatureImage::ImageDimension>>
60class ITK_TEMPLATE_EXPORT LabelMapContourOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
61{
62public:
63 ITK_DISALLOW_COPY_AND_MOVE(LabelMapContourOverlayImageFilter);
64
70
72 using LabelMapType = TLabelMap;
76 using LabelMapPixelType = typename LabelMapType::PixelType;
77 using LabelObjectType = typename LabelMapType::LabelObjectType;
78 using LabelType = typename LabelObjectType::LabelType;
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 LabelMapDimension = TLabelMap::ImageDimension;
100 static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
101 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
102
103 enum
104 {
105 PLAIN = 0,
106 CONTOUR = 1,
107 SLICE_CONTOUR = 2
108 };
109
110 enum
111 {
112 HIGH_LABEL_ON_TOP = 0,
113 LOW_LABEL_ON_TOP = 1
114 };
115
117 itkNewMacro(Self);
118
120 itkOverrideGetNameOfClassMacro(LabelMapContourOverlayImageFilter);
121
123 void
124 SetFeatureImage(TFeatureImage * input)
125 {
126 // Process object is not const-correct so the const casting is required.
127 this->SetNthInput(1, const_cast<TFeatureImage *>(input));
128 }
129
131 FeatureImageType *
133 {
134 return itkDynamicCastInDebugMode<FeatureImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
135 }
136
138 void
139 SetInput1(TLabelMap * input)
140 {
141 this->SetInput(input);
142 }
143
145 void
146 SetInput2(TFeatureImage * input)
147 {
148 this->SetFeatureImage(input);
149 }
150
154 itkSetMacro(Opacity, double);
155 itkGetConstReferenceMacro(Opacity, double);
160 itkSetMacro(Type, int);
161 itkGetConstReferenceMacro(Type, int);
166 itkSetMacro(Priority, int);
167 itkGetConstReferenceMacro(Priority, int);
172 itkSetMacro(DilationRadius, SizeType);
173 itkGetConstReferenceMacro(DilationRadius, SizeType);
178 itkSetMacro(ContourThickness, SizeType);
179 itkGetConstReferenceMacro(ContourThickness, SizeType);
184 itkSetMacro(SliceDimension, int);
185 itkGetConstReferenceMacro(SliceDimension, int);
191 virtual void
192 SetFunctor(const FunctorType & functor)
193 {
194 if (m_Functor != functor)
195 {
196 m_Functor = functor;
197 this->Modified();
198 }
199 }
202 {
203 return m_Functor;
204 }
205 const FunctorType &
207 {
208 return m_Functor;
209 }
212protected:
215
219 void
221
223 void
224 EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
225
226 void
228
229 void
230 DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
231
232 // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
233 void
235 {
236 Superclass::DynamicThreadedGenerateData(outputRegion);
237 }
238
239 void
240 GenerateData() override;
241
242 void
244
245 void
247
248 void
249 PrintSelf(std::ostream & os, Indent indent) const override;
250
252 GetLabelMap() override
253 {
254 return m_TempImage;
255 }
256
257private:
258 double m_Opacity{};
259 int m_Type{};
260 int m_Priority{};
261 SizeType m_ContourThickness{};
262 SizeType m_DilationRadius{};
263 int m_SliceDimension{};
264 FunctorType m_Functor{};
265
266 LabelMapPointer m_TempImage{};
267
268}; // end of class
269
270} // end namespace itk
271
272#ifndef ITK_MANUAL_INSTANTIATION
273# include "itkLabelMapContourOverlayImageFilter.hxx"
274#endif
275
276#endif
Base class for all data objects in ITK.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Apply a colormap to the contours (outlines) of each object in a label map and superimpose it on top o...
typename OutputImageType::RegionType OutputImageRegionType
typename FeatureImageType::ConstPointer FeatureImageConstPointer
typename LabelMapType::LabelObjectType LabelObjectType
typename OutputImageType::ConstPointer OutputImageConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
void PrintSelf(std::ostream &os, Indent indent) const override
~LabelMapContourOverlayImageFilter() override=default
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
typename FeatureImageType::RegionType FeatureImageRegionType
virtual void SetFunctor(const FunctorType &functor)
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
void EnlargeOutputRequestedRegion(DataObject *) override
typename FeatureImageType::PixelType FeatureImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Base class for filters that take an image as input and overwrite that image as the output.
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....