ITK  6.0.0
Insight Toolkit
itkVoronoiSegmentationImageFilterBase.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 itkVoronoiSegmentationImageFilterBase_h
19#define itkVoronoiSegmentationImageFilterBase_h
20
23#include "itkImage.h"
24
25namespace itk
26{
58template <typename TInputImage, typename TOutputImage, typename TBinaryPriorImage = Image<unsigned char, 2>>
59class ITK_TEMPLATE_EXPORT VoronoiSegmentationImageFilterBase : public ImageToImageFilter<TInputImage, TOutputImage>
60{
61public:
62 ITK_DISALLOW_COPY_AND_MOVE(VoronoiSegmentationImageFilterBase);
63
69
71 itkNewMacro(Self);
72
74 itkOverrideGetNameOfClassMacro(VoronoiSegmentationImageFilterBase);
75
77 static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
78
80 using InputImageType = TInputImage;
86 using PixelType = typename TInputImage::PixelType;
87
88 using OutputImageType = TOutputImage;
89 using OutputPixelType = typename TOutputImage::PixelType;
90
97 using PointIdIterator = typename CellType::PointIdIterator;
103 using PointTypeVector = std::vector<PointType>;
104 using PointTypeDeque = std::deque<PointType>;
105 using BinaryObjectImage = TBinaryPriorImage;
107 using IndexList = std::vector<IndexType>;
108
112
114 itkSetMacro(NumberOfSeeds, int);
115 itkGetConstMacro(NumberOfSeeds, int);
119 itkSetMacro(MinRegion, SizeValueType);
120 itkGetConstMacro(MinRegion, SizeValueType);
125 itkSetMacro(Steps, int);
126 itkGetConstMacro(Steps, int);
130 itkGetConstMacro(LastStepSeeds, int);
131
133 itkGetConstMacro(NumberOfSeedsToAdded, int);
134
136 itkSetMacro(UseBackgroundInAPrior, bool);
137 itkGetConstMacro(UseBackgroundInAPrior, bool);
141 itkSetMacro(OutputBoundary, bool);
142 itkGetConstMacro(OutputBoundary, bool);
147 itkSetMacro(InteractiveSegmentation, bool);
148 itkGetConstMacro(InteractiveSegmentation, bool);
149 itkBooleanMacro(InteractiveSegmentation);
153 itkSetMacro(MeanDeviation, double);
154 itkGetConstMacro(MeanDeviation, double);
158 itkSetMacro(Size, SizeType);
159 itkGetConstMacro(Size, SizeType);
164 virtual void
166 {}
167
169 void
171
173 void
175
177 virtual void
179
180 virtual void
182
186 {
187 return m_WorkingVD;
188 }
189
190#if !defined(ITK_WRAPPING_PARSER) // generates invalid iterator instantiation
191 // with msvc
195 void
196 SetSeeds(int num, SeedsIterator begin)
197 {
198 m_NumberOfSeeds = num;
199 m_WorkingVD->SetSeeds(num, begin);
200 }
203#endif
204
208 void
210 {
211 m_NumberOfSeeds = seeds.size();
212 auto it = seeds.begin();
213 m_WorkingVD->SetSeeds(m_NumberOfSeeds, it);
214 }
219 GetSeed(int SeedID)
220 {
221 return m_WorkingVD->GetSeed(SeedID);
222 }
223
225 void
226 DrawDiagram(VDImagePointer result, unsigned char incolor, unsigned char outcolor, unsigned char boundcolor);
227
228 void
230
233 void
235
238 void
240
241protected:
244 void
245 PrintSelf(std::ostream & os, Indent indent) const override;
246
247 void
248 GenerateData() override; // general pipeline function.
249
250 SizeType m_Size{};
251 int m_NumberOfSeeds{ 200 };
252 SizeValueType m_MinRegion{ 20 };
253 int m_Steps{ 0 };
254 int m_LastStepSeeds{ 0 };
255 int m_NumberOfSeedsToAdded{ 0 };
256 int m_NumberOfBoundary{ 0 };
257
258 std::vector<SizeValueType> m_NumberOfPixels{};
259 std::vector<unsigned char> m_Label{};
260
261 double m_MeanDeviation{ 0.8 };
262 bool m_UseBackgroundInAPrior{ false };
263 bool m_OutputBoundary{ false }; // if =1 then output the boundaries, if = 0 then
264 // output the object.
265 bool m_InteractiveSegmentation{ false };
266
267 typename VoronoiDiagram::Pointer m_WorkingVD{};
268
269 typename VoronoiDiagramGenerator::Pointer m_VDGenerator{};
270
271 std::vector<PointType> m_SeedsToAdded{};
272
273 // private methods:
274 // Classify all the voronoi cells as interior , exterior or boundary.
275 virtual void
277
278 // Generate the seeds to be added by dividing the boundary cells.
279 virtual void
281
282 // Compute the statistics of the pixels inside the cell.
283 void
285
286 virtual bool
288 {
289 return true;
290 }
291
292 void
294
295 // Draw a straight line to the output image.
296 void
298
299 // Draw the intermediate Voronoi Diagram structure.
300 void
301 drawVDline(VDImagePointer result, PointType p1, PointType p2, unsigned char color);
302};
303} // namespace itk
304
305#ifndef ITK_MANUAL_INSTANTIATION
306# include "itkVoronoiSegmentationImageFilterBase.hxx"
307#endif
308
309#endif
An abstract interface for cells.
Base class for all data objects in ITK.
Base class for all process objects that output image data.
TOutputImage OutputImageType
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::ConstPointer InputImageConstPointer
typename InputImageType::Pointer InputImagePointer
Templated n-dimensional image class.
Definition: itkImage.h:89
Control indentation during Print() invocation.
Definition: itkIndent.h:50
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Implement the Sweep Line Algorithm for the construction of the 2D Voronoi Diagram.
Implements the 2-Dimensional Voronoi Diagram.
typename std::vector< VoronoiEdge >::iterator VoronoiEdgeIterator
typename SeedsType::iterator SeedsIterator
typename INTvector::iterator NeighborIdIterator
std::vector< PointType > SeedsType
Base class for VoronoiSegmentationImageFilter.
void PrintSelf(std::ostream &os, Indent indent) const override
typename VoronoiDiagram::VoronoiEdgeIterator EdgeIterator
void drawVDline(VDImagePointer result, PointType p1, PointType p2, unsigned char color)
void DrawDiagram(VDImagePointer result, unsigned char incolor, unsigned char outcolor, unsigned char boundcolor)
void EnlargeOutputRequestedRegion(DataObject *output) override
typename VoronoiDiagram::CellAutoPointer CellAutoPointer
void GetPixelIndexFromPolygon(PointTypeDeque vertlist, IndexList *PixelPool)
typename VoronoiDiagram::SeedsIterator SeedsIterator
typename BinaryObjectImage::Pointer BinaryObjectImagePointer
~VoronoiSegmentationImageFilterBase() override=default
void drawLine(PointType p1, PointType p2)
typename VoronoiDiagram::NeighborIdIterator NeighborIdIterator
void FillPolygon(PointTypeDeque vertlist, OutputPixelType color=1)
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:70